Add database migration script
See original GitHub issueWe’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:
$ terracotta migrate mysql://example.com
Found Terracotta database v0.7.3 (this is v0.8.0)
Bump database to v0.8.0? (y/N)
Performing database migration ...
Done!
$ terracotta migrate mysql://example2.com
Found Terracotta database v0.0.1 (this is v0.8.0)
Error: cannot auto-migrate. Please re-create database.
$ terracotta migrate mysql://example3.com
Found Terracotta database v0.8.1 (this is v0.8.0)
Nothing to do
This requires some sort of incremental changelog that specifies the necessary transformations between versions.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Using Migration Scripts in Database Deployments - Simple Talk
A SQL migration script is similar to a SQL build script, except that it changes a database from one version to another, rather...
Read more >Code First Migrations - EF6 - Microsoft Learn
We want a script to go from an empty database ($InitialDatabase) to the latest version (migration AddPostAbstract). If you don't specify a ...
Read more >Database Migration — Writing Scripts & Best Practices - Medium
Manual Migration Script — this is a script written by a database programmer. Sometimes it is impossible for a tool to create a...
Read more >Code-Based Migration in Entity Framework 6
Update-Database: Executes the last migration file created by the Add-Migration command and applies changes to the database schema.
Read more >Migration scripts introduction and general review
The main purpose of using the migration scripts is to ensure that database changes, being made and committed to source control, can be...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
verify=False
to disable all checks: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
NotImplementedError
).I’m hesitant whether we need a migration library at all. Some simple
ALTER TABLE
statements should do it. I suggest we use SQLalchemy to connect to the DB, then run the migration viaengine.execute
and raw SQL.@nickeopti could you perhaps imagine writing the SQLalchemy boilerplate for this? 😬 Then I can finish up the actual migrations and CLI and such.