M240521070855BodyFatScaleAddColumn.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M240521070855BodyFatScaleAddColumn
  6. */
  7. class M240521070855BodyFatScaleAddColumn extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $this->execute("ALTER TABLE `qimall_user_extra`
  15. ADD COLUMN `target_weight` DECIMAL(5,2) NOT NULL DEFAULT 0 COMMENT '目标体重',
  16. ADD COLUMN `body_weight` DECIMAL(5,2) NOT NULL DEFAULT '0.00' COMMENT '体重' AFTER `target_weight`,
  17. ADD COLUMN `body_height` DECIMAL(5,2) NOT NULL DEFAULT '0.00' COMMENT '身高' AFTER `body_weight`;");
  18. }
  19. /**
  20. * {@inheritdoc}
  21. */
  22. public function safeDown()
  23. {
  24. echo "M240521070855BodyFatScaleAddColumn cannot be reverted.\n";
  25. return false;
  26. }
  27. /*
  28. // Use up()/down() to run migration code without a transaction.
  29. public function up()
  30. {
  31. }
  32. public function down()
  33. {
  34. echo "M240521070855BodyFatScaleAddColumn cannot be reverted.\n";
  35. return false;
  36. }
  37. */
  38. }