3
2
forked from Dniel97/artemis

add database downgrading

This commit is contained in:
Hay1tsme 2024-03-04 00:50:51 -05:00
parent bc2b883fa9
commit c4deff9d1c
2 changed files with 13 additions and 1 deletions

View File

@ -118,7 +118,13 @@ class Data:
def schema_upgrade(self, ver: str = None):
self.__alembic_cmd(
"upgrade",
"head",
"head" if not ver else ver,
)
def schema_downgrade(self, ver: str):
self.__alembic_cmd(
"downgrade",
ver,
)
async def create_owner(self, email: Optional[str] = None, code: Optional[str] = "00000000000000000000") -> None:

View File

@ -48,6 +48,12 @@ if __name__ == "__main__":
elif args.action == "upgrade":
data.schema_upgrade(args.version)
elif args.action == "downgrade":
if not args.version:
logging.getLogger("database").error(f"Version argument required for downgrade")
exit(1)
data.schema_downgrade(args.version)
elif args.action == "create-owner":
loop = asyncio.get_event_loop()
loop.run_until_complete(data.create_owner(args.email, args.access_code))