| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace app\migrations;
- use common\models\rbac\AuthItem;
- use common\models\user\MemberLabel;
- use yii\db\Migration;
- /**
- * Class M230601165236UpdateQimallMenu
- */
- class M230601165236UpdateQimallMenu extends Migration
- {
- /**
- * {@inheritdoc}
- */
- public function safeUp()
- {
- try {
- // 修改菜单
- $sql = "UPDATE `qimall_menu` SET `pid` = 34, `tree` = 'tr_0 tr_34 ' WHERE `url` = 'mall/user-label/index' and `title` = '智能标签';
- UPDATE `qimall_rbac_auth_item` SET `pid` = 2820, `tree` = 'tr_0 tr_2820 ' WHERE `title` = '智能标签';";
- $this->execute($sql);
- // 获取权限id
- $itemId = AuthItem::find()->select('id')->where(['title' => '智能标签', 'status' => 1])->scalar();
- $rbac_sql = "UPDATE `qimall_rbac_auth_item` SET `level` = 3, `tree` = 'tr_0 tr_2820 tr_{$itemId} ' WHERE `pid` = {$itemId};";
- $this->execute($rbac_sql);
- } catch (\Exception $e) {
- \Yii::error('智能标签菜单转移:' . $e->getMessage());
- }
- }
- /**
- * {@inheritdoc}
- */
- public function safeDown()
- {
- echo "M230601165236UpdateQimallMenu cannot be reverted.\n";
- return false;
- }
- /*
- // Use up()/down() to run migration code without a transaction.
- public function up()
- {
- }
- public function down()
- {
- echo "M230601165236UpdateQimallMenu cannot be reverted.\n";
- return false;
- }
- */
- }
|