From fc3f0900b3c6002b13ab1809a85c33a32f06435f Mon Sep 17 00:00:00 2001 From: Kevin Trocolli Date: Thu, 11 Jan 2024 20:48:27 -0500 Subject: [PATCH] dbutils: add create-revision command --- core/data/database.py | 10 ++++++++++ dbutils.py | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/core/data/database.py b/core/data/database.py index b259b2b..1d2793b 100644 --- a/core/data/database.py +++ b/core/data/database.py @@ -219,3 +219,13 @@ class Data: return True + async def create_revision(self, message: str) -> None: + if not message: + self.logger.info("Message is required for create-revision") + return + + self.__alembic_cmd( + "revision", + "-m", + message, + ) diff --git a/dbutils.py b/dbutils.py index e10b814..d5af6c6 100644 --- a/dbutils.py +++ b/dbutils.py @@ -21,6 +21,7 @@ if __name__ == "__main__": ) parser.add_argument("--email", "-e", type=str, help="Email for the new user") parser.add_argument("--access_code", "-a", type=str, help="Access code for new/transfer user", default="00000000000000000000") + parser.add_argument("--message", "-m", type=str, help="Revision message") parser.add_argument("action", type=str, help="create, upgrade, create-owner") args = parser.parse_args() @@ -56,5 +57,9 @@ if __name__ == "__main__": loop = asyncio.get_event_loop() loop.run_until_complete(data.migrate()) + elif args.action == "create-revision": + loop = asyncio.get_event_loop() + loop.run_until_complete(data.create_revision(args.message)) + else: logging.getLogger("database").info(f"Unknown action {args.action}")