Skip to content

Commit

Permalink
Rename triggers to include schema for uniqueness in schema based mult…
Browse files Browse the repository at this point in the history
…i-tenant environments (#583)

Co-authored-by: Charles Lambert <ce.lambert@gmail.com>
  • Loading branch information
celamb4 and Charles Lambert authored Dec 5, 2024
1 parent e6bc23a commit 3ba10a3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pgsync/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ def create_triggers(
]:
self.drop_triggers(schema, [table])
queries.append(
f'CREATE TRIGGER "{table}_{name}" '
f'CREATE TRIGGER "{schema}_{table}_{name}" '
f'AFTER {" OR ".join(tg_op)} ON "{schema}"."{table}" '
f"FOR EACH {level} EXECUTE PROCEDURE "
f"{schema}.{TRIGGER_FUNC}()",
Expand All @@ -696,7 +696,7 @@ def drop_triggers(
logger.debug(f"Dropping trigger on table: {schema}.{table}")
for name in ("notify", "truncate"):
queries.append(
f'DROP TRIGGER IF EXISTS "{table}_{name}" ON '
f'DROP TRIGGER IF EXISTS "{schema}_{table}_{name}" ON '
f'"{schema}"."{table}"'
)
if join_queries:
Expand Down Expand Up @@ -732,7 +732,7 @@ def disable_trigger(self, schema: str, table: str) -> None:
self.execute(
sa.text(
f'ALTER TABLE "{schema}"."{table}" '
f"DISABLE TRIGGER {table}_{name}"
f"DISABLE TRIGGER {schema}_{table}_{name}"
)
)

Expand All @@ -749,7 +749,7 @@ def enable_trigger(self, schema: str, table, str) -> None:
self.execute(
sa.text(
f'ALTER TABLE "{schema}"."{table}" '
f"ENABLE TRIGGER {table}_{name}"
f"ENABLE TRIGGER {schema}_{table}_{name}"
)
)

Expand Down

0 comments on commit 3ba10a3

Please sign in to comment.