Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

package update resets modified rbac data #129

Open
tonwi opened this issue Mar 1, 2015 · 9 comments
Open

package update resets modified rbac data #129

tonwi opened this issue Mar 1, 2015 · 9 comments

Comments

@tonwi
Copy link

tonwi commented Mar 1, 2015

Hi there
using Yii2-start as basic template for a new app, I modified RBAC-data (new permissions, new roles etc.)
Today's package update (yii2-start-rbac-module) did reset my modifications.
Well - that's my own issue; I fixed it by make a copy of my rbac-data.......
Question:
is there a other possibility to use my own data set? do you have any hint?
regards

@vova07
Copy link
Owner

vova07 commented Mar 1, 2015

Hi,
If you are about data directory, than it's easy to fix: you just need to specify your own files in config file.
I mean that you can create your own data directory, and store there your datas. Config routes must be like: @common/my-data-directory/items.php or similar.
Good luck!

@golles
Copy link

golles commented Mar 4, 2015

I noticed the same. Is it possible to switch to DB instead of files? I saw with Yii 2.0.3 there is improvement for DB caching so I guess it's good to move to the db.

@vova07
Copy link
Owner

vova07 commented Mar 4, 2015

@golles Yes, it's possible.
To switch Yii2-Start to DB manager, you must follow next steps:

  • In config file in authManager section you need to switch to DbManager class.
  • Also you need to remove unneeded settings from the same authManager section.
    I mean: itemFile, assignmentFile and ruleFile.
  • Now you need to run migration command to create the DbManager tables in your DB:
    yii migrate --migrationPath=@yii/rbac/migrations/
  • After you need to run again all commands from 7'th step of app installation. Look at README file.
    php yii rbac/rbac/init
    php yii users/rbac/add
    php yii blogs/rbac/add
    php yii comments/rbac/add
  • And finally switch all your own roles, permissions to DB
  • Profit!

@golles
Copy link

golles commented Mar 4, 2015

What about the tables? Are they generated automatically?

@vova07
Copy link
Owner

vova07 commented Mar 4, 2015

Ah yes. Also you need to run migration command after you configure your authManager.
yii migrate --migrationPath=@yii/rbac/migrations/
I updated instruction. See precedent comment if it's not clear.

@golles
Copy link

golles commented Mar 4, 2015

Just saw it in the yii repo. Thanks mate!

@golles
Copy link

golles commented Mar 4, 2015

Setup is so easy. However I wanted to add viewblogs to user and when I save I get this error:

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`golles`.`yii2_auth_item`, CONSTRAINT `yii2_auth_item_ibfk_1` FOREIGN KEY (`rule_name`) REFERENCES `yii2_auth_rule` (`name`) ON DELETE SET NULL ON UPDATE CASCADE)

Any clue what is going wrong?

@vova07
Copy link
Owner

vova07 commented Mar 4, 2015

maybe you try to add some rule like dependency that not exist?

@CTOlet
Copy link

CTOlet commented Jun 9, 2015

Проблема в том, что поле ruleName является пустой строкой. Если передавать NULL то все ок. Пока сделал костыль if ($model->ruleName == '') $model->ruleName = null; перед вставкой в БД

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants