M241021112959AlterWeightAddonsStoreGoodsAttr.php 817 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace addons\Store\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * 修改商品重量weight 字段 int(11) 为 decimal(10,2)
  6. * Class M241021112959AlterWeightAddonsStoreGoodsAttr
  7. */
  8. class M241021112959AlterWeightAddonsStoreGoodsAttr extends Migration
  9. {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function safeUp()
  14. {
  15. try {
  16. $sql = <<<SQL
  17. ALTER TABLE `qimall_addons_store_goods_attr` MODIFY COLUMN `weight` decimal(10, 2) NOT NULL DEFAULT 0 COMMENT '重量(克)' AFTER `goods_no`;
  18. SQL;
  19. $this->execute($sql);
  20. } catch (\Exception $e) {
  21. }
  22. }
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public function safeDown()
  27. {
  28. echo "M241021112959AlterWeightAddonsStoreGoodsAttr cannot be reverted.\n";
  29. return false;
  30. }
  31. }