M230206065257AddCommunityToOrder.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M230206065257AddCommunityToOrder
  6. */
  7. class M230206065257AddCommunityToOrder extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. try {
  15. $sql = "ALTER TABLE `qimall_order` ADD COLUMN `community` INT(11) UNSIGNED NOT NULL DEFAULT '0' COMMENT '小区ID' AFTER `town`;
  16. ALTER TABLE `qimall_user_address`
  17. ADD COLUMN `community_id` INT UNSIGNED NOT NULL DEFAULT '0' COMMENT '小区ID' AFTER `town`,
  18. ADD COLUMN `community` VARCHAR(255) NULL DEFAULT NULL COMMENT '小区名称' AFTER `community_id`;";
  19. $this->execute($sql);
  20. } catch (\Exception $e) {
  21. }
  22. }
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public function safeDown()
  27. {
  28. echo "M230206065257AddCommunityToOrder cannot be reverted.\n";
  29. return false;
  30. }
  31. /*
  32. // Use up()/down() to run migration code without a transaction.
  33. public function up()
  34. {
  35. }
  36. public function down()
  37. {
  38. echo "M230206065257AddCommunityToOrder cannot be reverted.\n";
  39. return false;
  40. }
  41. */
  42. }