Skip to content

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

Merge migrations

François Zaninotto5dda9a42d2bd
diff --git a/registry.json b/registry.json
index b26b0aa6..5058b9ff 100644
--- a/registry.json
+++ b/registry.json
@@ -124,7 +124,7 @@
"type": "registry:component"
},
{
- "path": "src/components/atomic-crm/settings/AppConfigPage.tsx",
+ "path": "src/components/atomic-crm/settings/ProfilePage.tsx",
"type": "registry:component"
},
{
diff --git a/supabase/migrations/20260211194545_app_configuration.sql b/supabase/migrations/20260211194545_app_configuration.sql
index 457028b1..fefa0972 100644
--- a/supabase/migrations/20260211194545_app_configuration.sql
+++ b/supabase/migrations/20260211194545_app_configuration.sql
@@ -1,3 +1,8 @@
+-- Singleton table storing the app configuration as a JSONB document.
+-- Admins can customize branding, company sectors, deal stages/categories,
+-- note statuses, and task types via the Settings page.
+-- The app merges stored values with code defaults, so missing keys are safe.
+
create table "public"."configuration" (
"id" integer not null default 1,
"config" jsonb not null default '{}'::jsonb,
@@ -34,3 +39,39 @@ grant select, insert, update on "public"."configuration" to "service_role";
-- Seed empty config (code defaults apply)
insert into "public"."configuration" ("id", "config") values (1, '{}'::jsonb);
+
+-- Migrate old label-based values to slug-based values.
+--
+-- Previously, companySectors, dealCategories, and taskTypes were stored as
+-- plain string arrays (e.g. ["Energy", "Copywriting"]) in individual records.
+-- Now they use a { value, label } format where `value` is a slug derived from
+-- the label.
+--
+-- This converts record fields (companies.sector, deals.category, tasks.type,
+-- contact_notes.status) from display labels to slugs.
+
+CREATE OR REPLACE FUNCTION pg_temp.to_slug(label text) RETURNS text AS $$
+BEGIN
+ RETURN TRIM(BOTH '-' FROM REGEXP_REPLACE(LOWER(label), '[^a-z0-9]+', '-', 'g'));
+END;
+$$ LANGUAGE plpgsql IMMUTABLE;
+
+UPDATE companies
+SET sector = pg_temp.to_slug(sector)
+WHERE sector IS NOT NULL
+ AND sector != pg_temp.to_slug(sector);
+
+UPDATE deals
+SET category = pg_temp.to_slug(category)
+WHERE category IS NOT NULL
+ AND category != pg_temp.to_slug(category);
+
+UPDATE tasks
+SET type = pg_temp.to_slug(type)
+WHERE type IS NOT NULL
+ AND type != pg_temp.to_slug(type);
+
+UPDATE contact_notes
+SET status = pg_temp.to_slug(status)
+WHERE status IS NOT NULL
+ AND status != pg_temp.to_slug(status);
diff --git a/supabase/migrations/20260215134709_slugify_labeled_values.sql b/supabase/migrations/20260215134709_slugify_labeled_values.sql
deleted file mode 100644
index 9a842f2e..00000000
--- a/supabase/migrations/20260215134709_slugify_labeled_values.sql
+++ /dev/null
@@ -1,40 +0,0 @@
--- Migrate old label-based values to slug-based values.
---
--- Previously, companySectors, dealCategories, and taskTypes were stored as
--- plain string arrays (e.g. ["Energy", "Copywriting"]) in individual records.
--- Now they use a { value, label } format where `value` is a slug derived from
--- the label.
---
--- This migration converts record fields (companies.sector, deals.category, tasks.type,
--- contact_notes.status) from display labels to slugs.
-
--- Helper: replicates the toSlug() TypeScript function
-CREATE OR REPLACE FUNCTION pg_temp.to_slug(label text) RETURNS text AS $$
-BEGIN
- RETURN TRIM(BOTH '-' FROM REGEXP_REPLACE(LOWER(label), '[^a-z0-9]+', '-', 'g'));
-END;
-$$ LANGUAGE plpgsql IMMUTABLE;
-
--- Slugify record fields
--- Only update rows where the value differs from its slug form
-
-UPDATE companies
-SET sector = pg_temp.to_slug(sector)
-WHERE sector IS NOT NULL
- AND sector != pg_temp.to_slug(sector);
-
-UPDATE deals
-SET category = pg_temp.to_slug(category)
-WHERE category IS NOT NULL
- AND category != pg_temp.to_slug(category);
-
-UPDATE tasks
-SET type = pg_temp.to_slug(type)
-WHERE type IS NOT NULL
- AND type != pg_temp.to_slug(type);
-
-UPDATE contact_notes
-SET status = pg_temp.to_slug(status)
-WHERE status IS NOT NULL
- AND status != pg_temp.to_slug(status);
-