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

Create a migration feature for Casbin schema changes #63

Open
Sefriol opened this issue Mar 16, 2022 · 4 comments
Open

Create a migration feature for Casbin schema changes #63

Sefriol opened this issue Mar 16, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@Sefriol
Copy link
Contributor

Sefriol commented Mar 16, 2022

Following up the discussion had here, mongoose adapter needs a way to adapt possible schema changes to ensure that previous users of the adapter have a possibility reliable and documented way to upgrade to a new version.

This requires some thinking and design. However the bare minimum should involve:

  1. Migrations are done via transactions if available.
  2. You should be able to downgrade a migration as well. Incase there are some something goes wrong.
  3. Adapter should probably check that each migration is done before being operational.
  4. Migrations should be put under tests.
@casbin-bot
Copy link

@casbin-bot casbin-bot added the question Further information is requested label Mar 16, 2022
@hsluoyz hsluoyz added enhancement New feature or request and removed question Further information is requested labels Mar 16, 2022
@Sefriol
Copy link
Contributor Author

Sefriol commented Mar 17, 2022

@Shivansh-yadav13
Copy link
Contributor

hey, @Sefriol I have some idea with migrate-mongo but how is it going to be a feature of the adapter? I am a little confused.

@Sefriol
Copy link
Contributor Author

Sefriol commented Mar 17, 2022

Adapter needs to identify that database schema is old and needs to be updated before use. migrate-mongo would take care of the update and then adapter would work as expected.

I think in this particular case it would just update (up()) all documents with p_type to ptype and possibility to downgrade (down()), converting all documents back to p_type. This should be quite reliable with MongoDB transactions.

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

No branches or pull requests

4 participants