Skip to content

Commit

Permalink
Merge pull request #1454 from ponder-sh/kjs/reorg-scope
Browse files Browse the repository at this point in the history
fix: reorg trigger namespacing
  • Loading branch information
kyscott18 authored Jan 20, 2025
2 parents 7d8997c + 1495900 commit c1ff36c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/gold-foxes-act.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ponder": patch
---

Fixed a bug with schema awareness when two ponder apps are in the same database.
4 changes: 2 additions & 2 deletions packages/core/src/database/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ export const createDatabase = ({

await sql
.raw(`
CREATE OR REPLACE FUNCTION ${tableName.triggerFn}
CREATE OR REPLACE FUNCTION "${preBuild.namespace}".${tableName.triggerFn}
RETURNS TRIGGER AS $$
BEGIN
IF TG_OP = 'INSERT' THEN
Expand All @@ -1038,7 +1038,7 @@ $$ LANGUAGE plpgsql
.raw(`
CREATE OR REPLACE TRIGGER "${tableName.trigger}"
AFTER INSERT OR UPDATE OR DELETE ON "${preBuild.namespace}"."${tableName.sql}"
FOR EACH ROW EXECUTE FUNCTION ${tableName.triggerFn};
FOR EACH ROW EXECUTE FUNCTION "${preBuild.namespace}".${tableName.triggerFn};
`)
.execute(qb.internal);
}
Expand Down

0 comments on commit c1ff36c

Please sign in to comment.