M240926103303QimallAddonsReservationServiceStoreGoods.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace addons\ReservationService\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M240926103303QimallAddonsReservationServiceStoreGoods
  6. */
  7. class M240926103303QimallAddonsReservationServiceStoreGoods extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $table = 'qimall_addons_reservation_service_store_goods';
  15. $sql="select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
  16. $res = $this->db->createCommand($sql)->execute();
  17. if(empty($res)){
  18. $sql="
  19. CREATE TABLE `qimall_addons_reservation_service_store_goods` (
  20. `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
  21. `user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '用户ID',
  22. `store_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '门店id',
  23. `goods_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '绑定的商品ID',
  24. `created_at` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  25. `updated_at` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
  26. `mall_id` int(10) unsigned NOT NULL COMMENT '商城ID',
  27. `status` tinyint(3) NOT NULL DEFAULT '1' COMMENT '状态0禁用,-1删除,1正常',
  28. PRIMARY KEY (`id`) USING BTREE,
  29. KEY `user_id` (`user_id`) USING BTREE,
  30. KEY `store_id` (`store_id`) USING BTREE,
  31. KEY `goods_id` (`goods_id`) USING BTREE
  32. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='技师绑定的o2o门店项目';";
  33. $this->execute($sql);
  34. }
  35. $table = 'qimall_addons_reservation_service_occupy';
  36. $sql = "select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
  37. $res = $this->db->createCommand($sql)->execute();
  38. if (empty($res)) {
  39. $sql = "
  40. CREATE TABLE `qimall_addons_reservation_service_occupy` (
  41. `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
  42. `mall_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '商城ID',
  43. `store_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '门店ID',
  44. `staff_user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '技师用户ID',
  45. `start_at` int(11) NOT NULL DEFAULT '0' COMMENT '服务开始时间',
  46. `end_at` int(11) NOT NULL DEFAULT '0' COMMENT '服务结束时间',
  47. `status` tinyint(3) NOT NULL DEFAULT '1' COMMENT '状态0禁用,-1删除,1正常',
  48. `created_at` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
  49. `updated_at` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
  50. PRIMARY KEY (`id`) USING BTREE,
  51. KEY `staff_user_id` (`staff_user_id`) USING BTREE
  52. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='技师占用记录';
  53. ";
  54. $this->execute($sql);
  55. }
  56. }
  57. /**
  58. * {@inheritdoc}
  59. */
  60. public function safeDown()
  61. {
  62. echo "M240926103303QimallAddonsReservationServiceStoreGoods cannot be reverted.\n";
  63. return false;
  64. }
  65. /*
  66. // Use up()/down() to run migration code without a transaction.
  67. public function up()
  68. {
  69. }
  70. public function down()
  71. {
  72. echo "M240926103303QimallAddonsReservationServiceStoreGoods cannot be reverted.\n";
  73. return false;
  74. }
  75. */
  76. }