M241209094147UpdateQimallMenu.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace app\migrations;
  3. use common\models\backend\Menu;
  4. use yii\db\Migration;
  5. /**
  6. * Class M241209094147UpdateQimallMenu
  7. */
  8. class M241209094147UpdateQimallMenu extends Migration
  9. {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function safeUp()
  14. {
  15. $menu = Menu::find()->where(['title' => '日志记录', 'cate_id' => 2])->asArray()->one();
  16. if (!empty($menu)) {
  17. $sql = "update qimall_menu set pid =".$menu['id']." where title = '操作日志' and cate_id = 2;
  18. update qimall_menu set pid =".$menu['id']." where title = '短信日志' and cate_id = 2;";
  19. $this->execute($sql);
  20. }
  21. }
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function safeDown()
  26. {
  27. echo "M241209094147UpdateQimallMenu cannot be reverted.\n";
  28. return false;
  29. }
  30. /*
  31. // Use up()/down() to run migration code without a transaction.
  32. public function up()
  33. {
  34. }
  35. public function down()
  36. {
  37. echo "M241209094147UpdateQimallMenu cannot be reverted.\n";
  38. return false;
  39. }
  40. */
  41. }