M240618082145AddIsPrintToQimallOrderTable.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M240618082145AddIsPrintToQimallOrderTable
  6. */
  7. class M240618082145AddIsPrintToQimallOrderTable extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. try {
  15. $sql = <<<SQL
  16. ALTER TABLE `qimall_order`
  17. ADD COLUMN `is_print` TINYINT(1) NULL DEFAULT 0 COMMENT '是否已打印 0 否 1 是';
  18. SQL;
  19. $this->execute($sql);
  20. } catch (\Exception $e) {
  21. echo "Error adding column is_print to table qimall_order: " . $e->getMessage() . "\n";
  22. }
  23. }
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public function safeDown()
  28. {
  29. echo "M240618082145AddIsPrintToQimallOrderTable cannot be reverted.\n";
  30. return false;
  31. }
  32. /*
  33. // Use up()/down() to run migration code without a transaction.
  34. public function up()
  35. {
  36. }
  37. public function down()
  38. {
  39. echo "M240618082145AddIsPrintToQimallOrderTable cannot be reverted.\n";
  40. return false;
  41. }
  42. */
  43. }