Skip to content

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

update migration to include type

Jean-Baptiste Kaisera7a644a7f513
diff --git a/supabase/migrations/20250109152531_email_array.sql b/supabase/migrations/20250109152531_email_array.sql
index c0778fd1..be5a74e4 100644
--- a/supabase/migrations/20250109152531_email_array.sql
+++ b/supabase/migrations/20250109152531_email_array.sql
@@ -1,13 +1,11 @@
-alter table contacts add column email_array text[];
+alter table contacts add column email_jsonb jsonb;
-update contacts set email_array = array[email];
+update contacts set email_jsonb = ('[{"email": ' || email || ', "type": "Other"}]')::jsonb;
drop view contacts_summary;
alter table contacts drop column email;
-alter table contacts rename column email_array to email;
-
create view contacts_summary
as
select
@@ -16,7 +14,8 @@ select
co.last_name,
co.gender,
co.title,
- co.email,
+ co.email_jsonb,
+ jsonb_path_query_array(co.email_jsonb, '$[*].email')::text as email_fts,
co.phone_1_number,
co.phone_1_type,
co.phone_2_number,