diff --git a/ui/medashare/alembic/README b/ui/medashare/alembic/README index e05fd38..3fdb292 100644 --- a/ui/medashare/alembic/README +++ b/ui/medashare/alembic/README @@ -1,7 +1,36 @@ New Version ----------- -To create a revision, update the ORM in medashare/orm.py. +First make a test in `_TestMigrations` with the data that you will need. +Use the first 5 characters for the test name. Then dump the data to a +file so that it can be read back in. From the test fixture that setups +the data, use the code: +``` +tf = pathlib.Path('fixtures/test_.sqlite').absolute() +engine_file = sqlalchemy.create_engine('sqlite+pysqlite:///' + str(tf)) +raw_connection_file = engine_file.raw_connection() + +objcon.backup(raw_connection_file.connection) + +raw_connection_file.close() +engine_file.dispose() +objcon.close() +``` + +Then you can comment it out, or use `if False: #pragma: no cover` and +replace it with the following to load the saved database: +``` + +objcon = self._engine.raw_connection() +engine_file = sqlalchemy.create_engine('sqlite+pysqlite:///' + str(tf)) +raw_connection_file = engine_file.raw_connection() +raw_connection_file.connection.backup(objcon.connection) +raw_connection_file.close() +engine_file.dispose() +objcon.close() +``` + +Update the ORM in `medashare/orm.py` as needed. Then in the medashare directory, run: ``` @@ -9,7 +38,10 @@ Then in the medashare directory, run: ``` This will create a version file. Edit the version file to support the -migration (such as populating new columns). +migration (such as populating new columns or tables). + +Finish the test for the migration. Note, you may need to update code +to handle older versions. This can be handled by calling xxx. (TODO) Once things are tested as good, commit everything.