m220227_143427_common_notify.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. use yii\db\Migration;
  3. class m220227_143427_common_notify extends Migration
  4. {
  5. public function up()
  6. {
  7. /* 取消外键约束 */
  8. $this->execute('SET foreign_key_checks = 0');
  9. /* 创建表 */
  10. $this->createTable('{{%common_notify}}', [
  11. 'id' => "bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键'",
  12. 'merchant_id' => "int(10) unsigned NULL DEFAULT '0' COMMENT '商户id'",
  13. 'store_id' => "int(10) unsigned NULL DEFAULT '0' COMMENT '店铺ID'",
  14. 'title' => "varchar(150) NULL DEFAULT '' COMMENT '标题'",
  15. 'content' => "varchar(300) NULL DEFAULT '' COMMENT '消息内容'",
  16. 'type' => "tinyint(1) NULL DEFAULT '0' COMMENT '消息类型[1:公告;2:提醒;3:信息(私信)'",
  17. 'target_id' => "int(10) NULL DEFAULT '0' COMMENT '目标id'",
  18. 'target_type' => "varchar(100) NULL DEFAULT '' COMMENT '目标类型'",
  19. 'target_display' => "int(10) NULL DEFAULT '1' COMMENT '目标者是否删除'",
  20. 'action' => "varchar(100) NULL DEFAULT '' COMMENT '动作'",
  21. 'view' => "int(10) NULL DEFAULT '0' COMMENT '浏览量'",
  22. 'sender_id' => "int(10) NULL DEFAULT '0' COMMENT '发送者id'",
  23. 'sender_display' => "tinyint(1) NULL DEFAULT '1' COMMENT '发送者是否删除'",
  24. 'sender_revocation' => "tinyint(1) NULL DEFAULT '1' COMMENT '是否撤回 0是撤回'",
  25. 'params' => "json NULL COMMENT '参数'",
  26. 'link' => "varchar(255) NULL DEFAULT '' COMMENT '详情链接'",
  27. 'status' => "tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]'",
  28. 'created_at' => "int(10) NOT NULL DEFAULT '0' COMMENT '创建时间'",
  29. 'updated_at' => "int(10) unsigned NULL DEFAULT '0' COMMENT '修改时间'",
  30. 'PRIMARY KEY (`id`)'
  31. ], "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='公用_消息公告表'");
  32. /* 索引设置 */
  33. $this->createIndex('target_type','{{%common_notify}}','target_type',0);
  34. $this->createIndex('merchant_id','{{%common_notify}}','merchant_id',0);
  35. /* 表数据 */
  36. /* 设置外键约束 */
  37. $this->execute('SET foreign_key_checks = 1;');
  38. }
  39. public function down()
  40. {
  41. $this->execute('SET foreign_key_checks = 0');
  42. /* 删除表 */
  43. $this->dropTable('{{%common_notify}}');
  44. $this->execute('SET foreign_key_checks = 1;');
  45. }
  46. }
粤ICP备19079148号