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

fix: default table name #79

Merged
merged 1 commit into from
Feb 23, 2021
Merged

fix: default table name #79

merged 1 commit into from
Feb 23, 2021

Conversation

kilosonc
Copy link
Contributor

Signed-off-by: closetool c299999999@qq.com

Fix: #78

@d1ss0nanz
Copy link

Cross posting from #78 since migration code is missing.

Ok, so up to at least 3.0.3, in some code paths, the created table is named "casbin_rules".
NewAdapterByDB() is behaving this way in 3.0.3.

Now, when updating to a more recent version, gorm-adapter is creating a new table "casbin_rule" besides the fact that there already exists a table "casbin_rules".

All authorization attempts silently fail, since the group membership data is in the old table.

I would suggest that you document the breaking change, so one doesn't have to understand how Gorm derives table names from struct names, to understand what's going on.

Optionally, there should be migration code that checks for a table "casbin_rules" and moves the data over when creating "casbin_rule".

@kilosonc
Copy link
Contributor Author

@d1ss0nanz Thinks for your suggestions. In my opinion, althought support data migration is quite simple, that's not a good choice to add DML in code. So I'll emphasize this change in readme.

Signed-off-by: closetool <c299999999@qq.com>
@kilosonc
Copy link
Contributor Author

kilosonc commented Feb 23, 2021

@d1ss0nanz @hsluoyz plz review

@hsluoyz hsluoyz merged commit a91399f into casbin:master Feb 23, 2021
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

Successfully merging this pull request may close these issues.

Behaviour of NewAdapterByDB() has a breaking change
3 participants