diff --git a/.changeset/gold-foxes-act.md b/.changeset/gold-foxes-act.md new file mode 100644 index 000000000..db3cbaa47 --- /dev/null +++ b/.changeset/gold-foxes-act.md @@ -0,0 +1,5 @@ +--- +"ponder": patch +--- + +Fixed a bug with schema awareness when two ponder apps are in the same database. diff --git a/packages/core/src/database/index.ts b/packages/core/src/database/index.ts index 6c88c1011..c3337d1bd 100644 --- a/packages/core/src/database/index.ts +++ b/packages/core/src/database/index.ts @@ -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 @@ -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); }