Skip to content

Commit

Permalink
feat: remove/add resource_snapshot from enum table
Browse files Browse the repository at this point in the history
this commit performs code cleanup and fixes #474
  • Loading branch information
JustKuzya committed Jan 16, 2025
1 parent 70daae4 commit d4898cc
Showing 1 changed file with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,20 @@ 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:
result = session.execute(statement)
session.commit()
# pprint(f'{dir(result)=}')
return result


# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------


def upgrade():
Expand All @@ -103,9 +99,7 @@ def upgrade():
delete(ResourceTypes).where(ResourceTypes.resource_type == "resource_snapshot")
)
execute_in_session(delete_statement)


# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------


def downgrade():
Expand Down Expand Up @@ -135,6 +129,4 @@ def downgrade():
insert(ResourceTypes).values(resource_type="resource_snapshot")
)
execute_in_session(insert_statement)


# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------

0 comments on commit d4898cc

Please sign in to comment.