m220227_143428_extend_config.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. use yii\db\Migration;
  3. class m220227_143428_extend_config extends Migration
  4. {
  5. public function up()
  6. {
  7. /* 取消外键约束 */
  8. $this->execute('SET foreign_key_checks = 0');
  9. /* 创建表 */
  10. $this->createTable('{{%extend_config}}', [
  11. 'id' => "int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键'",
  12. 'merchant_id' => "int(10) unsigned NULL DEFAULT '0' COMMENT '商户'",
  13. 'store_id' => "int(10) unsigned NULL DEFAULT '0' COMMENT '店铺ID'",
  14. 'store_id' => "int(10) NULL DEFAULT '0' COMMENT '门店'",
  15. 'title' => "varchar(50) NULL DEFAULT '' COMMENT '配置标题'",
  16. 'name' => "varchar(50) NULL DEFAULT '' COMMENT '配置标识'",
  17. 'type' => "varchar(30) NULL DEFAULT '' COMMENT '配置类型'",
  18. 'remark' => "varchar(1000) NULL DEFAULT '' COMMENT '说明'",
  19. 'data' => "json NULL COMMENT '配置'",
  20. 'sort' => "int(10) unsigned NULL DEFAULT '0' COMMENT '排序'",
  21. 'extend' => "int(10) NULL DEFAULT '0' COMMENT '扩展字段'",
  22. 'is_addon' => "tinyint(4) unsigned NULL DEFAULT '0' COMMENT '是否插件'",
  23. 'addon_name' => "varchar(200) NULL DEFAULT '' COMMENT '插件名称'",
  24. 'status' => "tinyint(4) NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]'",
  25. 'created_at' => "int(10) unsigned NULL DEFAULT '0' COMMENT '创建时间'",
  26. 'updated_at' => "int(10) unsigned NULL DEFAULT '0' COMMENT '修改时间'",
  27. 'PRIMARY KEY (`id`)'
  28. ], "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='扩展_配置表'");
  29. /* 索引设置 */
  30. $this->createIndex('type','{{%extend_config}}','type',0);
  31. $this->createIndex('uk_name','{{%extend_config}}','name',0);
  32. /* 表数据 */
  33. /* 设置外键约束 */
  34. $this->execute('SET foreign_key_checks = 1;');
  35. }
  36. public function down()
  37. {
  38. $this->execute('SET foreign_key_checks = 0');
  39. /* 删除表 */
  40. $this->dropTable('{{%extend_config}}');
  41. $this->execute('SET foreign_key_checks = 1;');
  42. }
  43. }
粤ICP备19079148号