-
Notifications
You must be signed in to change notification settings - Fork 77
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
Add database migration script #245
Comments
That would be sweet. I had this case a few dozen times when upgrading deployments. I usually just bump the version in the DB manually when I know that the schema did not change. This would be a nice tool for that. |
Since we are using SQLAlchemy, I would suggest using Alembic https://alembic.sqlalchemy.org/en/latest/ Alembic is a CLI tool, but they also have a python API, so you can call their migration commands from within your own tool. |
Sounds good to me. Let's just make it an optional dependency that we check for inside the migration script. |
Okay so I played around with alembic and ... didn't love it. The biggest problem (apart from the steep learning curve) is that modifying SQLite is not fully supported (for example re-naming tables which just ends in I'm hesitant whether we need a migration library at all. Some simple @nickeopti could you perhaps imagine writing the SQLalchemy boilerplate for this? 😬 Then I can finish up the actual migrations and CLI and such. |
I hope to get time to help at some point. Until then, this can probably get you started: We can actually use the driver logic, just set import sqlalchemy as sqla
from terracotta import drivers
driver = drivers.get_driver('<driver_path>')
with driver.connect(verify=False):
driver.meta_store.connection.execute(sqla.text('<raw sql statement>')) |
We've had the issue a couple of times where a new release breaks compatibility with the database format while not really changing much. The way this is handled in other libraries is by providing a migration script that works like this:
This requires some sort of incremental changelog that specifies the necessary transformations between versions.
The text was updated successfully, but these errors were encountered: