From d4898cc020f144a79494ad26fd75e106c822be34 Mon Sep 17 00:00:00 2001 From: Cousin Date: Thu, 16 Jan 2025 11:16:05 -0500 Subject: [PATCH] feat: remove/add resource_snapshot from enum table this commit performs code cleanup and fixes #474 --- ...eca33569_upgrade_resource_snapshot_types.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/dioptra/restapi/db/alembic/versions/0ca6eca33569_upgrade_resource_snapshot_types.py b/src/dioptra/restapi/db/alembic/versions/0ca6eca33569_upgrade_resource_snapshot_types.py index 4cc401e45..f8baf419e 100644 --- a/src/dioptra/restapi/db/alembic/versions/0ca6eca33569_upgrade_resource_snapshot_types.py +++ b/src/dioptra/restapi/db/alembic/versions/0ca6eca33569_upgrade_resource_snapshot_types.py @@ -72,14 +72,12 @@ def __repr__(self): # ------------------------------------------------------------------------- -# ============================================================================= - - -def execute_in_session(statement) -> CursorResult: +def execute_in_session(statement) -> CursorResult | None: """Reusable function to Execute SQL-Alchemy statement in a session Args: statement (_type_): _description_ """ + result = None bind = op.get_bind() Session = sessionmaker(bind=bind) with Session() as session: @@ -87,9 +85,7 @@ def execute_in_session(statement) -> CursorResult: session.commit() # pprint(f'{dir(result)=}') return result - - -# ----------------------------------------------------------------------------- + # ----------------------------------------------------------------------------- def upgrade(): @@ -103,9 +99,7 @@ def upgrade(): delete(ResourceTypes).where(ResourceTypes.resource_type == "resource_snapshot") ) execute_in_session(delete_statement) - - -# ----------------------------------------------------------------------------- + # ----------------------------------------------------------------------------- def downgrade(): @@ -135,6 +129,4 @@ def downgrade(): insert(ResourceTypes).values(resource_type="resource_snapshot") ) execute_in_session(insert_statement) - - -# ----------------------------------------------------------------------------- + # -----------------------------------------------------------------------------