M230329074657QimallUserMemberLabel.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M230329074657QimallUserMemberLabel
  6. */
  7. class M230329074657QimallUserMemberLabel extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. try {
  15. $table = 'qimall_user_member_label';
  16. $sql="select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
  17. $res = $this->db->createCommand($sql)->execute();
  18. if(!empty($res)) return '';
  19. $sql="CREATE TABLE `{$table}` (
  20. `id` bigint(10) NOT NULL AUTO_INCREMENT,
  21. `mall_id` int(10) NOT NULL DEFAULT '0' COMMENT '商城ID',
  22. `user_id` int(10) NOT NULL DEFAULT '0' COMMENT '会员ID',
  23. `cate_id1` int(11) NOT NULL DEFAULT '0' COMMENT '价值标签id',
  24. `cate_id2` int(11) NOT NULL DEFAULT '0' COMMENT '会员等级标签id',
  25. `cate_id3` int(11) NOT NULL DEFAULT '0' COMMENT '渠道等级标签id',
  26. `cate_id4` int(11) NOT NULL DEFAULT '0' COMMENT '复购标签id',
  27. `cate_id5` int(11) NOT NULL DEFAULT '0' COMMENT '推广标签id',
  28. `cate_id6` int(11) NOT NULL DEFAULT '0' COMMENT '领导标签id',
  29. `cate_id7` int(11) NOT NULL DEFAULT '0' COMMENT '活跃标签id',
  30. `cate_id8` int(11) NOT NULL DEFAULT '0' COMMENT '收入标签id',
  31. `cate_id9` int(11) NOT NULL DEFAULT '0' COMMENT '分享标签id',
  32. `cate_id10` int(11) NOT NULL DEFAULT '0' COMMENT '退款标签id',
  33. `cate_id11` int(11) NOT NULL DEFAULT '0' COMMENT '会员年龄标签id',
  34. `status` tinyint(4) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
  35. `register_time` int(11) NOT NULL DEFAULT '0',
  36. `created_at` int(11) NOT NULL DEFAULT '0',
  37. `updated_at` int(11) NOT NULL DEFAULT '0',
  38. PRIMARY KEY (`id`) USING BTREE,
  39. KEY `idx_user_id` (`user_id`) USING BTREE
  40. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员标签表';";
  41. $this->execute($sql);
  42. } catch (\Exception $e) {
  43. }
  44. }
  45. /**
  46. * {@inheritdoc}
  47. */
  48. public function safeDown()
  49. {
  50. echo "M230329074657QimallUserMemberLabel cannot be reverted.\n";
  51. return false;
  52. }
  53. /*
  54. // Use up()/down() to run migration code without a transaction.
  55. public function up()
  56. {
  57. }
  58. public function down()
  59. {
  60. echo "M230329074657QimallUserMemberLabel cannot be reverted.\n";
  61. return false;
  62. }
  63. */
  64. }