snapshot of https://github.com/marmelab/atomic-crm.git (main, 2026-09-18; blobs > 131072B omitted)
Some checks failed
✅ Check / 🔬 ESLint (push) Failing after 21s
✅ Check / 🏷️ Typecheck (push) Failing after 11s
✅ Check / 🔎 Test (push) Failing after 11s
✅ Check / e2e-test (push) Failing after 11s
✅ Check / 🔨 Build (push) Failing after 11s
🚀 Deploy / 🚀 Deploy (doc) (push) Failing after 12s
🚀 Deploy / 🚀 Deploy (demo) (push) Failing after 12s
🚀 Deploy / 🚀 Deploy (supabase) (push) Failing after 18s
Some checks failed
✅ Check / 🔬 ESLint (push) Failing after 21s
✅ Check / 🏷️ Typecheck (push) Failing after 11s
✅ Check / 🔎 Test (push) Failing after 11s
✅ Check / e2e-test (push) Failing after 11s
✅ Check / 🔨 Build (push) Failing after 11s
🚀 Deploy / 🚀 Deploy (doc) (push) Failing after 12s
🚀 Deploy / 🚀 Deploy (demo) (push) Failing after 12s
🚀 Deploy / 🚀 Deploy (supabase) (push) Failing after 18s
This commit is contained in:
80
supabase/schemas/04_triggers.sql
Normal file
80
supabase/schemas/04_triggers.sql
Normal file
@@ -0,0 +1,80 @@
|
||||
--
|
||||
-- Triggers
|
||||
-- This file declares all triggers.
|
||||
--
|
||||
|
||||
-- Auto-populate sales_id from current auth user on insert
|
||||
create or replace trigger set_company_sales_id_trigger
|
||||
before insert on public.companies
|
||||
for each row execute function public.set_sales_id_default();
|
||||
|
||||
create or replace trigger set_contact_sales_id_trigger
|
||||
before insert on public.contacts
|
||||
for each row execute function public.set_sales_id_default();
|
||||
|
||||
create or replace trigger set_contact_notes_sales_id_trigger
|
||||
before insert on public.contact_notes
|
||||
for each row execute function public.set_sales_id_default();
|
||||
|
||||
create or replace trigger set_deal_sales_id_trigger
|
||||
before insert on public.deals
|
||||
for each row execute function public.set_sales_id_default();
|
||||
|
||||
create or replace trigger set_deal_notes_sales_id_trigger
|
||||
before insert on public.deal_notes
|
||||
for each row execute function public.set_sales_id_default();
|
||||
|
||||
create or replace trigger set_task_sales_id_trigger
|
||||
before insert on public.tasks
|
||||
for each row execute function public.set_sales_id_default();
|
||||
|
||||
-- Auto-fetch company logo from website favicon on save
|
||||
create or replace trigger company_saved
|
||||
before insert or update on public.companies
|
||||
for each row execute function public.handle_company_saved();
|
||||
|
||||
-- Lowercase contact emails before insert or update (must run before contact_saved)
|
||||
create or replace trigger "10_lowercase_contact_emails"
|
||||
before insert or update on public.contacts
|
||||
for each row execute function public.lowercase_email_jsonb();
|
||||
|
||||
-- Auto-fetch contact avatar from email on save (runs after lowercase_contact_emails)
|
||||
create or replace trigger "20_contact_saved"
|
||||
before insert or update on public.contacts
|
||||
for each row execute function public.handle_contact_saved();
|
||||
|
||||
-- Update contact.last_seen when a contact note is created
|
||||
create or replace trigger on_public_contact_notes_created_or_updated
|
||||
after insert on public.contact_notes
|
||||
for each row execute function public.handle_contact_note_created_or_updated();
|
||||
|
||||
-- Cleanup storage attachments when contact notes are updated or deleted
|
||||
create or replace trigger on_contact_notes_attachments_updated_delete_note_attachments
|
||||
after update on public.contact_notes
|
||||
for each row
|
||||
when (old.attachments is distinct from new.attachments)
|
||||
execute function public.cleanup_note_attachments();
|
||||
|
||||
create or replace trigger on_contact_notes_deleted_delete_note_attachments
|
||||
after delete on public.contact_notes
|
||||
for each row execute function public.cleanup_note_attachments();
|
||||
|
||||
-- Cleanup storage attachments when deal notes are updated or deleted
|
||||
create or replace trigger on_deal_notes_attachments_updated_delete_note_attachments
|
||||
after update on public.deal_notes
|
||||
for each row
|
||||
when (old.attachments is distinct from new.attachments)
|
||||
execute function public.cleanup_note_attachments();
|
||||
|
||||
create or replace trigger on_deal_notes_deleted_delete_note_attachments
|
||||
after delete on public.deal_notes
|
||||
for each row execute function public.cleanup_note_attachments();
|
||||
|
||||
-- Auth triggers: sync auth.users to public.sales
|
||||
create or replace trigger on_auth_user_created
|
||||
after insert on auth.users
|
||||
for each row execute function public.handle_new_user();
|
||||
|
||||
create or replace trigger on_auth_user_updated
|
||||
after update on auth.users
|
||||
for each row execute function public.handle_update_user();
|
||||
Reference in New Issue
Block a user