Skip to content

db: Port database migration scripts from sqlalchemy-migrate to alembic - #478

Open
claudiubelu wants to merge 4 commits into
cloudbase:masterfrom
claudiubelu:alembic-migration-scripts
Open

db: Port database migration scripts from sqlalchemy-migrate to alembic#478
claudiubelu wants to merge 4 commits into
cloudbase:masterfrom
claudiubelu:alembic-migration-scripts

Conversation

@claudiubelu

Copy link
Copy Markdown
Member

oslo_db has deprecated sqlalchemy-migrate in favor of alembic, and the old facade no longer exists in current oslo.db releases.

Adds the alembic config, env, and template scaffolding.

Relocates the existing migrate_repo scripts under coriolis/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 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 oslo.db upper constraint is removed.

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.
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.

1 participant