M231214102305AddQimallMallHost.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M231214102305AddQimallMallHost
  6. */
  7. class M231214102305AddQimallMallHost extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $table = 'qimall_mall_host';
  15. $sql="select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
  16. $res = $this->db->createCommand($sql)->execute();
  17. if(!empty($res)) return '';
  18. $sql="CREATE TABLE `qimall_mall_host` (
  19. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  20. `mall_id` int(11) NOT NULL DEFAULT 0 COMMENT '商城id',
  21. `backend_url` varchar(255) NOT NULL DEFAULT '' COMMENT '后台管理域名',
  22. `h5_url` varchar(255) NOT NULL DEFAULT '' COMMENT 'h5域名',
  23. `api_url` varchar(255) NOT NULL DEFAULT '' COMMENT 'api域名',
  24. `static_url` varchar(255) NOT NULL DEFAULT '' COMMENT '静态资源域名',
  25. `is_custom_host` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否自定义域名',
  26. `created_at` int(11) NOT NULL DEFAULT '0',
  27. `updated_at` int(11) NOT NULL DEFAULT '0',
  28. `status` tinyint(4) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
  29. PRIMARY KEY (`id`) USING BTREE
  30. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='商城自定义域名';";
  31. $this->execute($sql);
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function safeDown()
  37. {
  38. echo "M231214102305AddQimallMallHost cannot be reverted.\n";
  39. return false;
  40. }
  41. /*
  42. // Use up()/down() to run migration code without a transaction.
  43. public function up()
  44. {
  45. }
  46. public function down()
  47. {
  48. echo "M231214102305AddQimallMallHost cannot be reverted.\n";
  49. return false;
  50. }
  51. */
  52. }