A full-featured CRM built with React, shadcn/ui, and Supabase.
Merge migrations related to imports into one
React-Admin CI672c446ec808
diff --git a/supabase/migrations/20260107151133_company_avatar.sql b/supabase/migrations/20260107151133_company_avatar.sqldeleted file mode 100644index 4f4381a7..00000000--- a/supabase/migrations/20260107151133_company_avatar.sql+++ /dev/null@@ -1,25 +0,0 @@-set check_function_bodies = off;--CREATE OR REPLACE FUNCTION public.handle_company_saved()- RETURNS trigger- LANGUAGE plpgsql-AS $function$declare company_logo text;--begin- if new.logo is not null then- return new;- end if;-- company_logo = get_domain_favicon(new.website);- if company_logo is null then- return new;- end if;-- new.logo = concat('{"src":"', company_logo, '","title":"Company favicon"}');- return new;-end;$function$-;--CREATE TRIGGER company_saved BEFORE INSERT OR UPDATE ON public.companies FOR EACH ROW EXECUTE FUNCTION public.handle_company_saved();--diff --git a/supabase/migrations/20260108100629_task_due_date_nullable.sql b/supabase/migrations/20260108100629_task_due_date_nullable.sqldeleted file mode 100644index f9e8c0e1..00000000--- a/supabase/migrations/20260108100629_task_due_date_nullable.sql+++ /dev/null@@ -1,3 +0,0 @@-alter table "public"."tasks" alter column "due_date" drop not null;--diff --git a/supabase/migrations/20260107140209_contact_avatar.sql b/supabase/migrations/20260127140209_imports.sqlsimilarity index 74%rename from supabase/migrations/20260107140209_contact_avatar.sqlrename to supabase/migrations/20260127140209_imports.sqlindex cf2f1ffe..df0d0c67 100644--- a/supabase/migrations/20260107140209_contact_avatar.sql+++ b/supabase/migrations/20260127140209_imports.sql@@ -1,9 +1,9 @@create extension if not exists "http" with schema "extensions";- create table "public"."favicons_excluded_domains" (+create table "public"."favicons_excluded_domains" ("id" bigint generated by default as identity not null,"domain" text not null- );+);alter table "public"."favicons_excluded_domains" enable row level security;@@ -12,6 +12,8 @@ CREATE UNIQUE INDEX favicons_excluded_domains_pkey ON public.favicons_excluded_dalter table "public"."favicons_excluded_domains" add constraint "favicons_excluded_domains_pkey" PRIMARY KEY using index "favicons_excluded_domains_pkey";+alter table "public"."tasks" alter column "due_date" drop not null;+set check_function_bodies = off;CREATE OR REPLACE FUNCTION public.get_avatar_for_email(email text)@@ -96,19 +98,7 @@ beginend;$function$;-grant delete on table "public"."favicons_excluded_domains" to "anon";--grant insert on table "public"."favicons_excluded_domains" to "anon";--grant references on table "public"."favicons_excluded_domains" to "anon";--grant select on table "public"."favicons_excluded_domains" to "anon";--grant trigger on table "public"."favicons_excluded_domains" to "anon";--grant truncate on table "public"."favicons_excluded_domains" to "anon";--grant update on table "public"."favicons_excluded_domains" to "anon";+CREATE TRIGGER contact_saved BEFORE INSERT OR UPDATE ON public.contacts FOR EACH ROW EXECUTE FUNCTION public.handle_contact_saved();grant delete on table "public"."favicons_excluded_domains" to "authenticated";@@ -153,7 +143,7 @@ grant truncate on table "public"."favicons_excluded_domains" to "service_role";grant update on table "public"."favicons_excluded_domains" to "service_role";- create policy "Enable access for authenticated users only"+create policy "Enable access for authenticated users only"on "public"."favicons_excluded_domains"as permissivefor all@@ -161,5 +151,50 @@ grant update on table "public"."favicons_excluded_domains" to "service_role";using (true)with check (true);+CREATE OR REPLACE FUNCTION public.handle_company_saved()+ RETURNS trigger+ LANGUAGE plpgsql+AS $function$declare company_logo text;-CREATE TRIGGER contact_saved BEFORE INSERT OR UPDATE ON public.contacts FOR EACH ROW EXECUTE FUNCTION public.handle_contact_saved();+begin+ if new.logo is not null then+ return new;+ end if;++ company_logo = get_domain_favicon(new.website);+ if company_logo is null then+ return new;+ end if;++ new.logo = concat('{"src":"', company_logo, '","title":"Company favicon"}');+ return new;+end;$function$+;++CREATE TRIGGER company_saved BEFORE INSERT OR UPDATE ON public.companies FOR EACH ROW EXECUTE FUNCTION public.handle_company_saved();++CREATE OR REPLACE FUNCTION public.handle_contact_note_created_or_updated()+ RETURNS trigger+ LANGUAGE plpgsql+ SECURITY DEFINER+ SET search_path TO ''+AS $function$+begin+ update public.contacts set last_seen = new.date where contacts.id = new.contact_id and contacts.last_seen < new.date;+ return new;+end;+$function$+;++CREATE 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();++CREATE OR REPLACE FUNCTION get_user_id_by_email(email TEXT)+RETURNS TABLE (id uuid)+SECURITY definer+AS $$+BEGIN+ RETURN QUERY SELECT au.id FROM auth.users au WHERE au.email = $1;+END;+$$ LANGUAGE plpgsql;++revoke execute on function public.get_user_id_by_email from anon, authenticated, public;diff --git a/supabase/migrations/20260129161921_contact_last_seen_from_notes.sql b/supabase/migrations/20260129161921_contact_last_seen_from_notes.sqldeleted file mode 100644index 778f4bd8..00000000--- a/supabase/migrations/20260129161921_contact_last_seen_from_notes.sql+++ /dev/null@@ -1,27 +0,0 @@-set check_function_bodies = off;--CREATE OR REPLACE FUNCTION public.handle_contact_note_created_or_updated()- RETURNS trigger- LANGUAGE plpgsql- SECURITY DEFINER- SET search_path TO ''-AS $function$-begin- update public.contacts set last_seen = new.date where contacts.id = new.contact_id and contacts.last_seen < new.date;- return new;-end;-$function$-;--CREATE 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();--CREATE OR REPLACE FUNCTION get_user_id_by_email(email TEXT)-RETURNS TABLE (id uuid)-SECURITY definer-AS $$-BEGIN- RETURN QUERY SELECT au.id FROM auth.users au WHERE au.email = $1;-END;-$$ LANGUAGE plpgsql;--revoke execute on function public.get_user_id_by_email from anon, authenticated, public;