sqlalchemy-migrate -> Alembic#4450
Conversation
amercader
left a comment
There was a problem hiding this comment.
@smotornyuk I had a very quick first look.
How will this work for existing installations that set up their database with sqlalchemy-migrate? Will it upgrade to the new version automatically with alembic or is there a step needed?
| # are written from script.py.mako | ||
| # output_encoding = utf-8 | ||
|
|
||
| sqlalchemy.url = postgresql://ckan_default:root@localhost/ckan_alembic |
There was a problem hiding this comment.
Is this DB actually used? is it a placeholder?
There was a problem hiding this comment.
Nope, this is default configuration file benerated durinig alembic initialization, that can be used for development purposes and debuging(for example, you can run all alembic commands directly from folder, containing alembic.ini), but CKAN commands(paster, etc.) are initialized with database url from main configuration file. Probably, i should set user:password and dbname to some base values, like ones from initial configuration file. Or this line may be removed at all...
| # encoding: utf-8 | ||
|
|
||
|
|
||
| def skip_based_on_legacy_engine_version(op, filename): |
There was a problem hiding this comment.
Can you explain what this function does or what is needed for?
There was a problem hiding this comment.
just a docsting would be nice e.g. "graceful upgrade from old migration numbers to alembic ids"
|
This looks good to me. The handling and deletion of the sqlalchemy migrate version is nice. |
|
|
||
|
|
||
| def downgrade(): | ||
| pass |
There was a problem hiding this comment.
maybe add a comment about creating migrate_version not being necessary once we've switched to alembic ids
|
@amercader this solution should be compatible with existing instances starting from ckan-2.5. I'm checking in every migration existing of sqlalcemy-migrate's version table via In short words, one have no need in any additional step(except for installing requirements.txt) for CKAN>=2.5. Any portal with CKAN<2.5 need to migrate first to some version in range 2.5 <= CKAN <=2.8 |
|
Another reason for moving to Alembic is because sqlalchemy-migrate is 'not maintained': https://groups.google.com/forum/#!topic/sqlalchemy/eF1DE20FMCQ |
|
I think this just needs conflicts resolved |
|
@wardi , i've updated PR. There are two new migrations that i've converted to alembic migrations and small changes in CLI commands for database management |
Co-Authored-By: David Read <[email protected]>
Use alembic instead of sqlalchemy-migrate. Main reason - I just like it. Second reason - it's more flexible and supports branching in an easy way. Third reason - sqlalchemy-migrate has some problems with python>=3.6
I rewrote all migrations in alembic so that we can safely drop sqlalchemy-migrate before switching to Py3. Theoretically, there will be no problem for new installations, where alembic is used to create the database from scratch. For existing portals, I'm going to use Alembic for all migrations that were added in CKAN>=2.5(starting from 82). That's mean, that portals that use CKAN<2.5 must use a three-step upgrade workflow:
As for CLI, I'm going to leave all commands as is and update commands internally, so there is no need in updating a lot of documentation or rewriting any of the existing installation scripts.
Are there any objections or suggestions?
PS Just for fun I'm also writing downgrade scripts, even thou I'm not sure whether they have any value