M231127033948AchievementColumnUpdate.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M231127033948AchievementColumnUpdate
  6. */
  7. class M231127033948AchievementColumnUpdate extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. return '';
  15. try{
  16. $tableName = 'qimall_addons_achievement_award_log';
  17. $table = \Yii::$app->db->getTableSchema($tableName, true);
  18. if(empty($table)) return true;
  19. $column = $table->getColumn('equal_info');
  20. if(empty($column)) return true;
  21. $sql = "ALTER TABLE `qimall_addons_achievement_award_log` MODIFY COLUMN `equal_info` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '首次平级奖励内容';";
  22. $this->execute($sql);
  23. }catch (\Exception $e){
  24. }
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function safeDown()
  30. {
  31. echo "M231127033948AchievementColumnUpdate cannot be reverted.\n";
  32. return false;
  33. }
  34. /*
  35. // Use up()/down() to run migration code without a transaction.
  36. public function up()
  37. {
  38. }
  39. public function down()
  40. {
  41. echo "M231127033948AchievementColumnUpdate cannot be reverted.\n";
  42. return false;
  43. }
  44. */
  45. }