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
tested.
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
hand.
There are plenty of examples of past migrations in the git history, for
example this is probably a good one:
https://git.beaker-project.org/cgit/beaker/commit/?id=da355153e4583da4e31...
op.add_column / op.drop_column are the ones you will want here too.
--
Dan Callaghan <dcallagh(a)redhat.com>
Senior Software Engineer, Products & Technologies Operations
Red Hat