M250225035230OrderReserveAddColumn.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M250225035230OrderReserveAddColumn
  6. */
  7. class M250225035230OrderReserveAddColumn extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $cursor = \Yii::$app->db->schema->getTableSchema('qimall_order_reserve', true);
  15. if ($cursor) {
  16. if (!$cursor->getColumn('service_start_at')) {
  17. $this->execute("alter table qimall_order_reserve add service_start_at int(11) not null default 0 comment'服务开始时间'");
  18. }
  19. if (!$cursor->getColumn('service_end_at')) {
  20. $this->execute("alter table qimall_order_reserve add service_end_at int(11) not null default 0 comment'服务结束时间'");
  21. }
  22. if (!$cursor->getColumn('goods_id')) {
  23. $this->execute("alter table qimall_order_reserve add goods_id int(11) not null default 0 comment'商品id'");
  24. }
  25. }
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function safeDown()
  31. {
  32. echo "M250225035230OrderReserveAddColumn cannot be reverted.\n";
  33. return false;
  34. }
  35. /*
  36. // Use up()/down() to run migration code without a transaction.
  37. public function up()
  38. {
  39. }
  40. public function down()
  41. {
  42. echo "M250225035230OrderReserveAddColumn cannot be reverted.\n";
  43. return false;
  44. }
  45. */
  46. }