Skip to content

Commit 6e56554

Browse files
committed
make preview seed trigger-safe
1 parent e931a54 commit 6e56554

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

supabase/migrations/20251026060000_baseline_schema.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ BEGIN
644644
EXECUTE FUNCTION "supabase_functions"."http_request"(
645645
'http://kong:8000/functions/v1/send-email-for-new-chat-message',
646646
'POST',
647-
'{"Content-type":"application/json","Authorization":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU"}',
647+
'{"Content-type":"application/json","Authorization":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0"}',
648648
'{}',
649649
'5000'
650650
)
@@ -945,4 +945,3 @@ ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT SELECT,INS
945945
ALTER DEFAULT PRIVILEGES FOR ROLE "postgres" IN SCHEMA "public" GRANT SELECT,INSERT,REFERENCES,DELETE,TRIGGER,TRUNCATE,UPDATE ON TABLES TO "service_role";
946946

947947

948-

supabase/seed.sql

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,18 @@ set
288288
initiator_id = excluded.initiator_id,
289289
owner_id = excluded.owner_id;
290290

291-
alter table public.chat_messages disable trigger webhook_new_chat_message;
291+
do $$
292+
begin
293+
if exists (
294+
select 1
295+
from pg_trigger
296+
where tgname = 'webhook_new_chat_message'
297+
and tgrelid = 'public.chat_messages'::regclass
298+
) then
299+
execute 'alter table public.chat_messages disable trigger webhook_new_chat_message';
300+
end if;
301+
end
302+
$$;
292303

293304
insert into public.chat_messages (
294305
id,
@@ -323,7 +334,18 @@ set
323334
content = excluded.content,
324335
read_at = excluded.read_at;
325336

326-
alter table public.chat_messages enable trigger webhook_new_chat_message;
337+
do $$
338+
begin
339+
if exists (
340+
select 1
341+
from pg_trigger
342+
where tgname = 'webhook_new_chat_message'
343+
and tgrelid = 'public.chat_messages'::regclass
344+
) then
345+
execute 'alter table public.chat_messages enable trigger webhook_new_chat_message';
346+
end if;
347+
end
348+
$$;
327349

328350
select
329351
'seed complete' as status,

0 commit comments

Comments
 (0)