M230107021645AddIsShowPriceToGoodsExtraTable.php 892 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M230107021645AddIsShowPriceToGoodsExtraTable
  6. */
  7. class M230107021645AddIsShowPriceToGoodsExtraTable extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. try {
  15. $this->addColumn('{{%goods_extra}}', 'is_show_price', $this->tinyInteger(4)->defaultValue(0)->comment('商品详情是否显示会员价'));
  16. }catch (\Exception $e){
  17. }
  18. }
  19. /**
  20. * {@inheritdoc}
  21. */
  22. public function safeDown()
  23. {
  24. $this->dropColumn('{{%goods_extra}}', 'is_show_price');
  25. }
  26. /*
  27. // Use up()/down() to run migration code without a transaction.
  28. public function up()
  29. {
  30. }
  31. public function down()
  32. {
  33. echo "M230107021645AddIsShowPriceToGoodsExtraTable cannot be reverted.\n";
  34. return false;
  35. }
  36. */
  37. }