Skip to content

Commit

Permalink
test that the new sql_down correctly drops everything
Browse files Browse the repository at this point in the history
  • Loading branch information
francojreyes committed May 30, 2024
1 parent 041e9d0 commit 50d963a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ def create_table(metadata: Metadata) -> CreateTableResult:
# Execute create table
cur.execute(metadata.sql_up)

# Test new sql_down
cur.execute(metadata.sql_down)
cur.execute(metadata.up)

# Store metadata
cmd = r"INSERT INTO Tables(table_name, up, down) VALUES (%s, %s, %s)"
cur.execute(cmd, (metadata.table_name, metadata.sql_up, metadata.sql_down))
Expand All @@ -94,6 +98,10 @@ def create_table(metadata: Metadata) -> CreateTableResult:
cur.execute(table_sql[1]) # old sql_down
cur.execute(metadata.sql_up)

# Test new sql_down
cur.execute(metadata.sql_down)
cur.execute(metadata.up)

# Store new metadata
cmd = r"UPDATE Tables SET up = %s, down = %s WHERE table_name = %s"
cur.execute(cmd, (metadata.sql_up, metadata.sql_down, metadata.table_name))
Expand Down

0 comments on commit 50d963a

Please sign in to comment.