vova07 / yii2-start

Yii2-Start application
Other
273 stars 115 forks source link

package update resets modified rbac data #129

Open tonwi opened 9 years ago

tonwi commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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

golles commented 9 years ago

What about the tables? Are they generated automatically?

vova07 commented 9 years ago

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 commented 9 years ago

Just saw it in the yii repo. Thanks mate!

golles commented 9 years ago

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 commented 9 years ago

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

CTOlet commented 9 years ago

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