M240627032048QimallRbacAuthItemDeleteMenuAndUpdate.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. use common\models\backend\Menu;
  5. /**
  6. * Class M240627032048QimallRbacAuthItemDeleteMenuAndUpdate
  7. */
  8. class M240627032048QimallRbacAuthItemDeleteMenuAndUpdate extends Migration
  9. {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function safeUp()
  14. {
  15. try {
  16. $res = Menu::migrateDeleteMenu();
  17. if ($res === false) throw new \Exception(Menu::getStaticError());
  18. }catch (\Exception $e){
  19. \Yii::error('删除重复的菜单错误:' . $e->getMessage());
  20. }
  21. }
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function safeDown()
  26. {
  27. echo "M240627032048QimallRbacAuthItemDeleteMenuAndUpdate 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 "M240627032048QimallRbacAuthItemDeleteMenuAndUpdate cannot be reverted.\n";
  38. return false;
  39. }
  40. */
  41. }