M240412073442SecondaryCard.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace addons\Store\console\migrations;
  3. use addons\Store\common\models\StoreMenu;
  4. use yii\db\Migration;
  5. /**
  6. * Class M240412073442SecondaryCard
  7. */
  8. class M240412073442SecondaryCard extends Migration
  9. {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function safeUp()
  14. {
  15. $model = StoreMenu::find()->where(['title'=>'次卡列表','addons_name'=>'SecondaryCard'])->orderBy('id asc')->one();
  16. $pid = $model['id'];
  17. $sql = "INSERT INTO `qimall_addons_store_menu` ( `title`, `app_id`, `pid`, `url`, `icon`, `level`, `dev`, `sort`, `params`, `tree`, `status`, `created_at`, `updated_at`, `addons_name`, `is_addon`) VALUES ( '使用记录', '0', '{$pid}', 'store/secondary-card/default/use-log', '', '2', '0', '999', NULL, '', '1', '0', '0', 'SecondaryCard', '1');";
  18. $model = StoreMenu::find()->where(['url'=>'store/secondary-card/default/use-log','addons_name'=>'SecondaryCard'])->orderBy('id asc')->one();
  19. if(empty($model)){
  20. $this->execute($sql);
  21. }
  22. }
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public function safeDown()
  27. {
  28. echo "M240412073442SecondaryCard 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 "M240412073442SecondaryCard cannot be reverted.\n";
  39. return false;
  40. }
  41. */
  42. }