M240627092827InsertQimallAddonsStoreMenu.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M240627092827InsertQimallAddonsStoreMenu
  6. */
  7. class M240627092827InsertQimallAddonsStoreMenu extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. try {
  15. $sql = <<<SQL
  16. INSERT INTO qimall_addons_store_menu (title, app_id, pid, addons_name, is_addon, url, icon, level, dev, sort, params, tree, status, created_at, updated_at)
  17. SELECT '自定义规格', '0', 2, '', 0, 'store/client/specs/index', '', 2, 0, 999, NULL, '', 1, 0, 0
  18. FROM DUAL
  19. WHERE NOT EXISTS (
  20. SELECT 1 FROM qimall_addons_store_menu WHERE url = 'store/client/specs/index'
  21. );
  22. SQL;
  23. $this->execute($sql);
  24. } catch (\Exception $e) {
  25. \Yii::error('增加自定义规格菜单错误了:' . $e->getMessage());
  26. }
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function safeDown()
  32. {
  33. echo "M240627092827InsertQimallAddonsStoreMenu cannot be reverted.\n";
  34. return false;
  35. }
  36. /*
  37. // Use up()/down() to run migration code without a transaction.
  38. public function up()
  39. {
  40. }
  41. public function down()
  42. {
  43. echo "M240627092827InsertQimallAddonsStoreMenu cannot be reverted.\n";
  44. return false;
  45. }
  46. */
  47. }