M250726022437InsertQimallDiyComponents.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M250726022437InsertQimallDiyComponents
  6. */
  7. class M250726022437InsertQimallDiyComponents extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. return true;
  15. try {
  16. $sql = <<<SQL
  17. INSERT INTO `qimall_diy_components`(`code`, `title`, `group`, `icon`, `count`, `is_top`, `permission`, `sort`, `source`, `status`, `created_at`, `updated_at`) VALUES ('luck-draw', '抽奖活动', 'marketing', '', 999, 0, '{\"is_drag\":\"true\",\"is_up\":\"true\",\"id_down\":\"true\",\"is_copy\":\"true\"}', 999, 'LuckDraw', 1, 1634538238, 1634538238);
  18. SQL;
  19. $this->execute($sql);
  20. } catch (\Exception $e) {
  21. // 处理异常
  22. var_dump($e->getMessage());
  23. }
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function safeDown()
  29. {
  30. echo "M250726022437InsertQimallDiyComponents cannot be reverted.\n";
  31. return false;
  32. }
  33. /*
  34. // Use up()/down() to run migration code without a transaction.
  35. public function up()
  36. {
  37. }
  38. public function down()
  39. {
  40. echo "M250726022437InsertQimallDiyComponents cannot be reverted.\n";
  41. return false;
  42. }
  43. */
  44. }