M230818061320UpdateQimallRbacAuthItem.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace app\migrations;
  3. use common\models\rbac\AuthItem;
  4. use common\models\rbac\AuthItemChild;
  5. use yii\db\Migration;
  6. /**
  7. * Class M230818061320UpdateQimallRbacAuthItem
  8. */
  9. class M230818061320UpdateQimallRbacAuthItem extends Migration
  10. {
  11. /**
  12. * {@inheritdoc}
  13. */
  14. public function safeUp()
  15. {
  16. try {
  17. $res = AuthItem::findOne(['id'=>'3313','name'=>'mall/addons/index','status'=>1]);
  18. if(!empty($res)){
  19. $res->status = -1;
  20. $res->save();
  21. AuthItemChild::deleteAll(['id'=>'3313','name'=>'mall/addons/index']);
  22. }
  23. $res = AuthItem::findOne(['id'=>'3370','name'=>'mall/addons/detail','status'=>1]);
  24. if(!empty($res)){
  25. $res->status = -1;
  26. $res->save();
  27. AuthItemChild::deleteAll(['id'=>'3370','name'=>'mall/addons/detail']);
  28. }
  29. }catch (\Exception $e){
  30. }
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function safeDown()
  36. {
  37. echo "M230818061320UpdateQimallRbacAuthItem cannot be reverted.\n";
  38. return false;
  39. }
  40. /*
  41. // Use up()/down() to run migration code without a transaction.
  42. public function up()
  43. {
  44. }
  45. public function down()
  46. {
  47. echo "M230818061320UpdateQimallRbacAuthItem cannot be reverted.\n";
  48. return false;
  49. }
  50. */
  51. }