diff options
author | Frederick Muriuki Muriithi | 2022-11-08 13:15:53 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-11-08 13:15:53 +0300 |
commit | 83c476a6738042e0ce35af07eb515d0a169c54ba (patch) | |
tree | 0ea2488a85e1db60b91b96a883b8da887eb429c7 | |
parent | 5deac1414efe34e29c8cea2976d31c2cc67b10b7 (diff) | |
download | genenetwork3-83c476a6738042e0ce35af07eb515d0a169c54ba.tar.gz |
CLI: Provide `apply-migrations` command for flask
* main.py: Provide the `apply-migrations` CLI command to run the migrations
against the auth database.
The command can be invoked with:
$ flask apply-migrations
-rw-r--r-- | main.py | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -4,6 +4,18 @@ from gn3.app import create_app app = create_app() +##### BEGIN: CLI Commands ##### + +@app.cli.command() +def apply_migrations(): + from yoyo import get_backend, read_migrations + from gn3.migrations import apply_migrations + apply_migrations( + get_backend(f'sqlite:///{app.config["AUTH_DB"]}'), + read_migrations(app.config["AUTH_MIGRATIONS"])) + +##### END: CLI Commands ##### + if __name__ == '__main__': print("Starting app...") app.run() |