M230216091033AddQimallAddonsStoreCollect.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace addons\Store\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M230216091033AddQimallAddonsStoreCollect
  6. */
  7. class M230216091033AddQimallAddonsStoreCollect extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $table = 'qimall_addons_store_collect';
  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_addons_store_collect` (
  19. `id` int(11) NOT NULL AUTO_INCREMENT,
  20. `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城id',
  21. `store_id` int(11) NOT NULL DEFAULT '0' COMMENT '商品id',
  22. `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '会员id',
  23. `status` tinyint(4) DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
  24. `created_at` int(11) NOT NULL DEFAULT '0',
  25. `updated_at` int(11) NOT NULL DEFAULT '0',
  26. PRIMARY KEY (`id`) USING BTREE
  27. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='门店收藏表';";
  28. $this->execute($sql);
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function safeDown()
  34. {
  35. echo "M230216091033AddQimallAddonsStoreCollect cannot be reverted.\n";
  36. return false;
  37. }
  38. /*
  39. // Use up()/down() to run migration code without a transaction.
  40. public function up()
  41. {
  42. }
  43. public function down()
  44. {
  45. echo "M230216091033AddQimallAddonsStoreCollect cannot be reverted.\n";
  46. return false;
  47. }
  48. */
  49. }