m230407_040351_addon_demo_curd_map.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. use yii\db\Migration;
  3. class m230407_040351_addon_demo_curd_map extends Migration
  4. {
  5. public function up()
  6. {
  7. /* 取消外键约束 */
  8. $this->execute('SET foreign_key_checks = 0');
  9. /* 创建表 */
  10. $this->createTable('{{%addon_demo_curd_map}}', [
  11. 'id' => "int(11) NOT NULL AUTO_INCREMENT",
  12. 'merchant_id' => "int(10) unsigned NULL DEFAULT '0' COMMENT '商户id'",
  13. 'curd_id' => "int(11) NULL DEFAULT '0'",
  14. 'name' => "varchar(100) NULL DEFAULT '' COMMENT '名称'",
  15. 'shipping_fee' => "decimal(10,2) unsigned NULL DEFAULT '0.00' COMMENT '运费'",
  16. 'type' => "varchar(50) NULL DEFAULT '' COMMENT '类型'",
  17. 'path' => "json NULL COMMENT '覆盖范围'",
  18. 'polygon' => "polygon NOT NULL",
  19. 'radius' => "decimal(10,2) NULL 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=InnoDB DEFAULT CHARSET=utf8mb4");
  25. /* 索引设置 */
  26. $this->createIndex('curd_id','{{%addon_demo_curd_map}}','curd_id',0);
  27. /* 表数据 */
  28. /* 设置外键约束 */
  29. $this->execute('SET foreign_key_checks = 1;');
  30. }
  31. public function down()
  32. {
  33. $this->execute('SET foreign_key_checks = 0');
  34. /* 删除表 */
  35. $this->dropTable('{{%addon_demo_curd_map}}');
  36. $this->execute('SET foreign_key_checks = 1;');
  37. }
  38. }
粤ICP备19079148号