Skip to content

A full-featured CRM built with React, shadcn/ui, and Supabase.

merge the migrations

erwanMarmelabfef42d08ad7c
diff --git a/supabase/migrations/20260907120000_search_index_view.sql b/supabase/migrations/20260907120000_search_index_view.sql
deleted file mode 100644
index 4ff96292..00000000
--- a/supabase/migrations/20260907120000_search_index_view.sql
+++ /dev/null
@@ -1,104 +0,0 @@
-create or replace view public.search_index with (security_invoker = on) as
-select
- ('company.' || c.id) as id,
- 'companies' as resource,
- c.id as record_id,
- c.name as title,
- c.sector as subtitle,
- concat_ws(' ', c.name, c.description, c.website, c.city) as content,
- c.id as company_id,
- null::bigint as contact_id,
- null::bigint as deal_id,
- c.created_at as date
-from public.companies c
-union all
-select
- ('contact.' || co.id) as id,
- 'contacts' as resource,
- co.id as record_id,
- concat_ws(' ', co.first_name, co.last_name) as title,
- cc.name as subtitle,
- concat_ws(
- ' ',
- co.first_name,
- co.last_name,
- co.title,
- cc.name,
- (jsonb_path_query_array(co.email_jsonb, '$[*]."email"'))::text,
- (jsonb_path_query_array(co.phone_jsonb, '$[*]."number"'))::text
- ) as content,
- co.company_id,
- co.id as contact_id,
- null::bigint as deal_id,
- co.first_seen as date
-from public.contacts co
- left join public.companies cc on cc.id = co.company_id
-union all
-select
- ('deal.' || d.id) as id,
- 'deals' as resource,
- d.id as record_id,
- d.name as title,
- dc.name as subtitle,
- concat_ws(' ', d.name, d.description, dc.name) as content,
- d.company_id,
- null::bigint as contact_id,
- d.id as deal_id,
- d.created_at as date
-from public.deals d
- left join public.companies dc on dc.id = d.company_id
-where d.archived_at is null
-union all
-select
- ('task.' || t.id) as id,
- 'tasks' as resource,
- t.id as record_id,
- t.text as title,
- concat_ws(' ', tco.first_name, tco.last_name) as subtitle,
- concat_ws(' ', t.text, t.type) as content,
- tco.company_id,
- t.contact_id,
- null::bigint as deal_id,
- t.due_date as date
-from public.tasks t
- left join public.contacts tco on tco.id = t.contact_id
-union all
-select
- ('contactNote.' || cn.id) as id,
- 'contact_notes' as resource,
- cn.id as record_id,
- cn.text as title,
- concat_ws(' ', nco.first_name, nco.last_name) as subtitle,
- concat_ws(
- ' ',
- cn.text,
- (select string_agg(a ->> 'title', ' ') from unnest(cn.attachments) as a)
- ) as content,
- nco.company_id,
- cn.contact_id,
- null::bigint as deal_id,
- cn.date
-from public.contact_notes cn
- left join public.contacts nco on nco.id = cn.contact_id
-union all
-select
- ('dealNote.' || dn.id) as id,
- 'deal_notes' as resource,
- dn.id as record_id,
- dn.text as title,
- nd.name as subtitle,
- concat_ws(
- ' ',
- dn.text,
- (select string_agg(a ->> 'title', ' ') from unnest(dn.attachments) as a)
- ) as content,
- nd.company_id,
- null::bigint as contact_id,
- dn.deal_id,
- dn.date
-from public.deal_notes dn
- left join public.deals nd on nd.id = dn.deal_id;
-
-grant all on table public.search_index to anon;
-grant all on table public.search_index to authenticated;
-grant all on table public.search_index to service_role;
diff --git a/supabase/migrations/20260910132555_global_search_review_fixes.sql b/supabase/migrations/20260910140459_global_search.sql
similarity index 98%
rename from supabase/migrations/20260910132555_global_search_review_fixes.sql
rename to supabase/migrations/20260910140459_global_search.sql
index d577241b..e099ff09 100644
--- a/supabase/migrations/20260910132555_global_search_review_fixes.sql
+++ b/supabase/migrations/20260910140459_global_search.sql
@@ -1,5 +1,3 @@
-drop view if exists "public"."search_index";
-
alter table "public"."tasks" add column "created_at" timestamp with time zone not null default now();
update "public"."tasks" set "created_at" = coalesce("done_date", "due_date", "created_at");