m220227_143427_common_attachment_cate.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. use yii\db\Migration;
  3. class m220227_143427_common_attachment_cate extends Migration
  4. {
  5. public function up()
  6. {
  7. /* 取消外键约束 */
  8. $this->execute('SET foreign_key_checks = 0');
  9. /* 创建表 */
  10. $this->createTable('{{%common_attachment_cate}}', [
  11. 'id' => "int(11) 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(100) NULL DEFAULT '' COMMENT '标题'",
  15. 'type' => "varchar(30) NULL DEFAULT '' COMMENT '类别'",
  16. 'sort' => "int(5) NULL DEFAULT '0' COMMENT '排序'",
  17. 'level' => "tinyint(1) NULL DEFAULT '1' COMMENT '级别'",
  18. 'pid' => "int(50) NULL DEFAULT '0' COMMENT '上级id'",
  19. 'tree' => "varchar(500) NULL DEFAULT '' COMMENT '树'",
  20. 'status' => "tinyint(4) NULL DEFAULT '1' COMMENT '状态'",
  21. 'created_at' => "int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间'",
  22. 'updated_at' => "int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间'",
  23. 'PRIMARY KEY (`id`)'
  24. ], "ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COMMENT='公用_资源文件分类'");
  25. /* 索引设置 */
  26. /* 表数据 */
  27. /* 设置外键约束 */
  28. $this->execute('SET foreign_key_checks = 1;');
  29. }
  30. public function down()
  31. {
  32. $this->execute('SET foreign_key_checks = 0');
  33. /* 删除表 */
  34. $this->dropTable('{{%common_attachment_cate}}');
  35. $this->execute('SET foreign_key_checks = 1;');
  36. }
  37. }
粤ICP备19079148号