M250830095139InsertGlobalVarMap.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. class M250830095139InsertGlobalVarMap extends Migration
  5. {
  6. /**
  7. * 在qimall_global_var_map这个枚举表中,增加一条记录
  8. */
  9. public function safeUp()
  10. {
  11. try {
  12. $sql = <<<SQL
  13. INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('a_equal_level_one', '平级奖', 'CapitalTypeMap', 0, 1, 1756518198, 1756518198);
  14. INSERT INTO `qimall_global_var_map` (`name`, `title`, `type`, `is_addons`, `status`, `created_at`, `updated_at`) VALUES ('a_equal_level_two', '平级奖', 'CapitalTypeMap', 0, 1, 1756518198, 1756518198);
  15. SQL;
  16. $this->execute($sql);
  17. } catch (\Exception $e) {
  18. // 处理异常
  19. var_dump($e->getMessage());
  20. }
  21. }
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function safeDown()
  26. {
  27. echo "M250830095139InsertGlobalVarMap cannot be reverted.\n";
  28. return false;
  29. }
  30. }