M240909025003InsertQimallDiyComponents.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace addons\SecondaryCard\console\migrations;
  3. use common\enums\StatusEnum;
  4. use common\models\diy\DiyComponents;
  5. use yii\db\Migration;
  6. /**
  7. * Class M240909025003InsertQimallDiyComponents
  8. */
  9. class M240909025003InsertQimallDiyComponents extends Migration
  10. {
  11. /**
  12. * {@inheritdoc}
  13. */
  14. public function safeUp()
  15. {
  16. $res = DiyComponents::find()->where(['code' => 'secondary-card', 'status' => StatusEnum::ENABLED])->one();
  17. if (!empty($res)) {
  18. return true;
  19. }
  20. $sql = "INSERT INTO `qimall_diy_components` ( `code`, `title`, `group`, `icon`, `count`, `is_top`, `permission`, `sort`, `source`, `status`, `created_at`, `updated_at`) VALUES ( 'secondary-card', '次卡', 'marketing', '', 999, 0, '{\"is_drag\":\"true\",\"is_up\":\"true\",\"id_down\":\"true\",\"is_copy\":\"true\"}', 999, 'SecondaryCard', 1, 1634538238, 1634538238);";
  21. $this->execute($sql);
  22. }
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public function safeDown()
  27. {
  28. echo "M240909025003InsertQimallDiyComponents cannot be reverted.\n";
  29. return false;
  30. }
  31. /*
  32. // Use up()/down() to run migration code without a transaction.
  33. public function up()
  34. {
  35. }
  36. public function down()
  37. {
  38. echo "M240909025003InsertQimallDiyComponents cannot be reverted.\n";
  39. return false;
  40. }
  41. */
  42. }