M221206104258AlterOrderExpressLog.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. *
  6. * Class M221206104258AlterOrderExpressLog
  7. */
  8. class M221206104258AlterOrderExpressLog extends Migration
  9. {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function safeUp()
  14. {
  15. $res = \Yii::$app->db->schema->getTableSchema("qimall_order_express_log",true);
  16. if(!$res->getColumn('table_express_status')){
  17. $sql = "ALTER TABLE `qimall_order_express_log`
  18. ADD COLUMN `table_express_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '物流状态0/未完成 1/已完成',
  19. ADD COLUMN `express_status` tinyint(2) NOT NULL DEFAULT '9' COMMENT '当前物流状态(物流公司状态)',
  20. MODIFY COLUMN `status` tinyint(5) NULL DEFAULT 1 COMMENT '状态[-1:删除;0:禁用;1启用]',
  21. ADD KEY `idx_table_exp_status_idx_mall_id` (`mall_id`,`table_express_status`);";
  22. $this->execute($sql);
  23. }
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function safeDown()
  29. {
  30. echo "M221206104258AlterOrderExpressLog cannot be reverted.\n";
  31. return false;
  32. }
  33. /*
  34. // Use up()/down() to run migration code without a transaction.
  35. public function up()
  36. {
  37. }
  38. public function down()
  39. {
  40. echo "M221206104258AlterOrderExpressLog cannot be reverted.\n";
  41. return false;
  42. }
  43. */
  44. }