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

WIP: moving to alembic #11060

Closed
wants to merge 5 commits into from
Closed

WIP: moving to alembic #11060

wants to merge 5 commits into from

Conversation

jdavcs
Copy link
Member

@jdavcs jdavcs commented Jan 6, 2021

Ref #10369

Very much WIP. First steps towards moving us to alembic. The new tests in the PR pass, the rest breaks, for now.

The alembic stuff is in model/migrations. There's a run function that handles the basic logic + a DBManager class that takes care of all db/alembic interactions. The steps are as follows:

  1. no database >> create, initialize, add alembic
  2. empty database >> initialize, add alembic
  3. nonempty database, alembic, up-to-date >> do nothing
  4. nonempty database, no migrate, no alembic >> fail, error message: require manual upgrade
  5. same + automigrate >> same: fail, error message: require manual upgrade
  6. nonempty database, has migrate, no alembic >> fail, error message: run db_manage script
  7. same + automigrate >> (we use SQLAlchemy migrate to upgrade to alembic revision#0 (when alembic was added), add alembic, upgrade to current revision)
  8. nonempty database, has alembic >> fail, error message: run db_manage script
  9. same + automigrate >> (upgrade to current revision)

My idea is to provide an automated upgrade path for db versions that already have SQLAlchemy Migrate, but not prior to that (I assume there's no reason to go that far back). This will be simpler than the current logic. I think we can phase out this path in 1-2 releases - that way we'll gradually remove SQLAlchemy Migrate from the code base.

The current implementation is far from complete. Also, I did not include views and triggers intentionally - I think it will make more sense to let alembic handle them (as a revision). Or maybe not.

@jdavcs jdavcs added kind/feature area/database Galaxy's database or data access layer area/scripts labels Jan 6, 2021
@jdavcs jdavcs added this to the 21.05 milestone Jan 6, 2021
@jdavcs jdavcs modified the milestones: 21.05, 21.09 Apr 7, 2021
@jdavcs jdavcs removed this from the 21.09 milestone Sep 2, 2021
@jdavcs jdavcs mentioned this pull request Nov 8, 2021
27 tasks
@jdavcs
Copy link
Member Author

jdavcs commented Nov 9, 2021

superseded by #12869

@jdavcs jdavcs closed this Nov 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/database Galaxy's database or data access layer area/scripts kind/feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants