Skip to content

Commit

Permalink
add superuser notice
Browse files Browse the repository at this point in the history
  • Loading branch information
HarukaMa committed Jan 29, 2024
1 parent a811e09 commit d70dabd
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions db/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ async def migrate_11_add_original_transaction_id_index(conn: psycopg.AsyncConnec
@staticmethod
async def migrate_12_set_on_delete_cascade(conn: psycopg.AsyncConnection[dict[str, Any]]):
# https://stackoverflow.com/a/74476119
await conn.execute(
"""
try:
await conn.execute("""
WITH tables(oid) AS (
UPDATE pg_constraint
SET confdeltype = 'c'
Expand All @@ -125,6 +125,10 @@ async def migrate_12_set_on_delete_cascade(conn: psycopg.AsyncConnection[dict[st
FROM tables
WHERE tables.oid = pg_trigger.tgrelid
AND tgtype = 9;
""",
(os.environ["DB_SCHEMA"],)
)
""", (os.environ["DB_SCHEMA"],)
)
except psycopg.errors.InsufficientPrivilege:
print("==========================")
print("You need superuser to run this migration")
print("==========================")
raise

0 comments on commit d70dabd

Please sign in to comment.