Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

- add backfill

Gaurav Bhattba38b78a3618
diff --git a/packages/database/supabase/migrations/20260326120000_fix-embedding-triggers.sql b/packages/database/supabase/migrations/20260326120000_fix-embedding-triggers.sql
index 1658243842..57d843da9d 100644
--- a/packages/database/supabase/migrations/20260326120000_fix-embedding-triggers.sql
+++ b/packages/database/supabase/migrations/20260326120000_fix-embedding-triggers.sql
@@ -80,3 +80,37 @@ BEGIN
RETURN NEW;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;
+
+-- =============================================================================
+-- PART 4: Backfill existing records with null embeddings
+-- =============================================================================
+
+SELECT pgmq.send(
+ 'embedding_jobs',
+ jsonb_build_object(
+ 'id', id,
+ 'table', 'item'
+ )
+)
+FROM item
+WHERE embedding IS NULL;
+
+SELECT pgmq.send(
+ 'embedding_jobs',
+ jsonb_build_object(
+ 'id', id,
+ 'table', 'supplier'
+ )
+)
+FROM supplier
+WHERE embedding IS NULL;
+
+SELECT pgmq.send(
+ 'embedding_jobs',
+ jsonb_build_object(
+ 'id', id,
+ 'table', 'customer'
+ )
+)
+FROM customer
+WHERE embedding IS NULL;