db: Port database migration scripts from sqlalchemy-migrate to alembic - #478
Open
claudiubelu wants to merge 4 commits into
Open
db: Port database migration scripts from sqlalchemy-migrate to alembic#478claudiubelu wants to merge 4 commits into
claudiubelu wants to merge 4 commits into
Conversation
oslo_db has deprecated sqlalchemy-migrate in favor of alembic, and the old facade no longer exists in current oslo.db releases. This adds the alembic config, env, and template scaffolding as the first step of porting coriolis-dbsync to alembic. The implementation is based on OpenStack Nova and Neutron.
Relocates the existing migrate_repo scripts under coriolis/db/sqlalchemy/alembic/versions/ using git move, so their history is preserved.
Updates database migrations to alembic. Most updates are straight-forward and repetitive, which some exceptions: 001, 016, 018, 020. In some scripts (e.g.: 001), the code was shifted around to account for the proper table creation order (e.g.: table Y might have a foreign key from table X). Scripts 014 and 016 deviate from the alembic db migration script pattern in order to keep diffs to a minimum. Downgrades are left unimplemented (raise NotImplementedError), matching the original scripts which never defined a downgrade() either.
Rewrites coriolis/db/sqlalchemy/migration.py to drive the alembic revision chain added instead of oslo_db.sqlalchemy.migration, which no longer exists in current oslo.db releases. db_sync auto-detects a pre-existing sqlalchemy-migrate `migrate_version` table left over from the old migrate_repo: if it's at the final version (24), it stamps the database onto the equivalent alembic revision instead of re-running already-applied migrations, then proceeds to upgrade normally. If the database is at any other legacy version, an exception will be raised, mentioning that upgrades must be finished with the previous release first. The now-empty migrate_repo/ is removed entirely. The oslo.db upper constraint is removed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
oslo_dbhas deprecatedsqlalchemy-migratein favor ofalembic, and the old facade no longer exists in currentoslo.dbreleases.Adds the alembic config, env, and template scaffolding.
Relocates the existing
migrate_reposcripts undercoriolis/db/sqlalchemy/alembic/versions/.Updates database migrations to alembic. Most updates are straight-forward and repetitive, which some exceptions:
001,016,018,020.In some scripts (e.g.:
001), the code was shifted around to account for the proper table creation order (e.g.: table Y might have a foreign key from table X).Scripts
014and016deviate from the alembic db migration script pattern in order to keep diffs to a minimum.Downgrades are left unimplemented (
raise NotImplementedError), matching the original scripts which never defined adowngrade()either.Rewrites
coriolis/db/sqlalchemy/migration.pyto drive the alembic revision chain added instead ofoslo_db.sqlalchemy.migration, which no longer exists in currentoslo.dbreleases.db_syncauto-detects a pre-existing sqlalchemy-migratemigrate_versiontable left over from the oldmigrate_repo: if it's at the final version (24), it stamps the database onto the equivalent alembic revision instead of re-running already-applied migrations, then proceeds to upgrade normally. If the database is at any other legacy version, an exception will be raised, mentioning that upgrades must be finished with the previous release first.The
oslo.dbupper constraint is removed.