On Mon, Jul 24, 2017 at 03:06:10PM +1000, Dan Callaghan wrote:
Excerpts from Don Zickus's message of 2017-07-20 11:12 -04:00:
> Hi Dan,
> Any followup on Jon's email? Also any tips on how to write database
> migration scripts for the changes we want to do?
In general you need an Alembic migration script, with upgrade and
downgrade steps. Running "alembic migrate" in the Server directory
should create a new empty migration with random id and the necessary
boilerplate, which you can fill in.
If the migration includes some step to migrate/transform data to a new
format then you would also include a test case that proves the
transformation does the right thing -- but in this case, just adding
some new columns with no values, there is no data transformation to be
Alembic can generate the migrations automatically by comparing an
existing database to the model definition, when you give it the
--autogenerate option... *but* for our database it typically does not
give usable results, because of deficiencies in how MySQL mangles the
schema. You are better off writing the upgrade/downgrade operations by
There are plenty of examples of past migrations in the git history, for
example this is probably a good one:
Thanks Dan! We did something like that last week, but we were using
'alembic upgrade/downgrade' instead of 'migration'. The upgrade kept
failing because of 'alembic no handlers found for logger alembic.migration'
or something. Thoughts there?