| @@ -1,7 +1,36 @@ | |||||
| New Version | 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_<oldversion>.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: | |||||
| ``` | |||||
| <tf from above> | |||||
| 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: | 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 | 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. | Once things are tested as good, commit everything. | ||||