M250425182123AddReservationServiceStoreSecondaryCard.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace addons\ReservationService\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * 创建预约表
  6. * Class M250425182123AddReservationServiceStoreSecondaryCard
  7. */
  8. class M250425182123AddReservationServiceStoreSecondaryCard extends Migration
  9. {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function safeUp()
  14. {
  15. // 判断表是否存在
  16. $table = 'qimall_addons_reservation_service_store_secondary_card';
  17. $sql="select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
  18. $res = $this->db->createCommand($sql)->execute();
  19. if(!empty($res)) return '';
  20. $sql="CREATE TABLE `qimall_addons_reservation_service_store_secondary_card` (
  21. `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
  22. `mall_id` int(11) unsigned NOT NULL COMMENT '商城ID',
  23. `user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '技师用户ID',
  24. `store_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '门店id',
  25. `secondary_card_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '绑定的次卡ID',
  26. `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态0禁用,-1删除,1正常',
  27. `created_at` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  28. `updated_at` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
  29. PRIMARY KEY (`id`) USING BTREE,
  30. KEY `user_id` (`user_id`) USING BTREE,
  31. KEY `store_id` (`store_id`) USING BTREE,
  32. KEY `secondary_card_id` (`secondary_card_id`) USING BTREE
  33. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='技师绑定的o2o门店次卡';";
  34. $this->execute($sql);
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function safeDown()
  40. {
  41. echo "M250425182123AddReservationServiceStoreSecondaryCard cannot be reverted.\n";
  42. return false;
  43. }
  44. }