M240522180009ModifyBannarPicLongText.php 787 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M240522180009ModifyBannarPicLongText
  6. */
  7. class M240522180009ModifyBannarPicLongText extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. try {
  15. $sql = <<<SQL
  16. ALTER TABLE `qimall_goods`
  17. MODIFY COLUMN `bannar_pic` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci
  18. NOT NULL COMMENT '商品展示bannar图' AFTER `cover_pic`;
  19. SQL;
  20. $this->execute($sql);
  21. } catch (\Exception $e) {
  22. }
  23. }
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public function safeDown()
  28. {
  29. echo "M240522180009ModifyBannarPicLongText cannot be reverted.\n";
  30. return false;
  31. }
  32. }