m220703_100616_common_theme.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. use yii\db\Migration;
  3. class m220703_100616_common_theme extends Migration
  4. {
  5. public function up()
  6. {
  7. /* 取消外键约束 */
  8. $this->execute('SET foreign_key_checks = 0');
  9. /* 创建表 */
  10. $this->createTable('{{%common_theme}}', [
  11. 'id' => "int(10) NOT NULL AUTO_INCREMENT COMMENT '主键'",
  12. 'merchant_id' => "int(10) NOT NULL DEFAULT '0' COMMENT '商户ID'",
  13. 'member_id' => "int(10) NULL DEFAULT '0' COMMENT '用户ID'",
  14. 'member_type' => "int(10) NULL DEFAULT '0' COMMENT '用户类型'",
  15. 'app_id' => "varchar(20) NOT NULL DEFAULT '' COMMENT '应用'",
  16. 'layout' => "varchar(50) NULL COMMENT '布局类型'",
  17. 'color' => "varchar(50) NULL DEFAULT 'black' COMMENT '主题颜色'",
  18. 'status' => "tinyint(4) NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]'",
  19. 'created_at' => "int(10) unsigned NULL DEFAULT '0' COMMENT '添加时间'",
  20. 'updated_at' => "int(10) unsigned NULL DEFAULT '0' COMMENT '修改时间'",
  21. 'PRIMARY KEY (`id`)'
  22. ], "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='公用_用户主题'");
  23. /* 索引设置 */
  24. $this->createIndex('member_id','{{%common_theme}}','member_id',0);
  25. /* 设置外键约束 */
  26. $this->execute('SET foreign_key_checks = 1;');
  27. }
  28. public function down()
  29. {
  30. $this->execute('SET foreign_key_checks = 0');
  31. /* 删除表 */
  32. $this->dropTable('{{%common_theme}}');
  33. $this->execute('SET foreign_key_checks = 1;');
  34. }
  35. }
粤ICP备19079148号