M240912074405CreateAgentBehaviorLogsTable.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace addons\Agent\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Handles the creation of table `{{%user_behavior_logs}}`.
  6. */
  7. class M240912074405CreateAgentBehaviorLogsTable extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $sql = <<<SQL
  15. CREATE TABLE `qimall_addons_agent_behavior_logs` (
  16. `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  17. `mall_id` int(10) unsigned NOT NULL DEFAULT '0',
  18. `operator_user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '操作人用户id',
  19. `operator_user_type` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '操作用户类型 1后台 2用户',
  20. `operator_target_user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '操作目标用户id',
  21. `behavior` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '1手动升级 2手动降级 3系统自动升级 4系统自动降级 5删除经销商 6 添加经销商',
  22. `desc` varchar(500) NOT NULL DEFAULT '',
  23. `extra_info` json DEFAULT NULL,
  24. `ip` int(10) unsigned NOT NULL DEFAULT '0',
  25. `status` tinyint(3) unsigned NOT NULL DEFAULT '1',
  26. `operation_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '实际操作时间',
  27. `created_at` int(10) unsigned NOT NULL DEFAULT '0',
  28. `updated_at` int(10) unsigned NOT NULL DEFAULT '0',
  29. PRIMARY KEY (`id`),
  30. KEY `operator_search_index` (`mall_id`,`operator_user_type`,`operator_user_id`,`behavior`),
  31. KEY `operator_target_search_index` (`mall_id`,`operator_target_user_id`,`behavior`)
  32. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='渠道分红用户行为日志表';
  33. SQL;
  34. $this->execute($sql);
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function safeDown()
  40. {
  41. return false;
  42. }
  43. }