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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
fix: fix migration to rebuild quotes and salesRfqs views
Rob Carringtonbf60fbe5c371
diff --git a/packages/database/src/types.ts b/packages/database/src/types.tsindex 0d73bbb4f8..e9b64d6ed2 100644--- a/packages/database/src/types.ts+++ b/packages/database/src/types.ts@@ -12210,9 +12210,10 @@ export type Database = {dueDate: string | nullestimatorId: string | nullexpirationDate: string | null+ externalNotes: Json | nullid: string+ internalNotes: Json | nulllocationId: string | null- notes: Json | nullquoteId: stringrevisionId: numbersalesPersonId: string | null@@ -12233,9 +12234,10 @@ export type Database = {dueDate?: string | nullestimatorId?: string | nullexpirationDate?: string | null+ externalNotes?: Json | nullid?: string+ internalNotes?: Json | nulllocationId?: string | null- notes?: Json | nullquoteId: stringrevisionId?: numbersalesPersonId?: string | null@@ -12256,9 +12258,10 @@ export type Database = {dueDate?: string | nullestimatorId?: string | nullexpirationDate?: string | null+ externalNotes?: Json | nullid?: string+ internalNotes?: Json | nulllocationId?: string | null- notes?: Json | nullquoteId?: stringrevisionId?: numbersalesPersonId?: string | null@@ -23842,12 +23845,13 @@ export type Database = {dueDate: string | nullestimatorId: string | nullexpirationDate: string | null+ externalNotes: Json | nullfavorite: boolean | nullid: string | null+ internalNotes: Json | nulllines: number | nulllocationId: string | nulllocationName: string | null- notes: Json | nullquoteId: string | nullrevisionId: number | nullsalesOrderId: string | null@@ -25031,12 +25035,12 @@ export type Database = {customFields: Json | nullemployeeId: string | nullexpirationDate: string | null+ externalNotes: Json | nullfavorite: boolean | nullid: string | nullinternalNotes: string | nulllocationId: string | nulllocationName: string | null- notes: Json | nullquoteId: string | nullrevisionId: number | nullrfqDate: string | nulldiff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.tsindex 0d73bbb4f8..e9b64d6ed2 100644--- a/packages/database/supabase/functions/lib/types.ts+++ b/packages/database/supabase/functions/lib/types.ts@@ -12210,9 +12210,10 @@ export type Database = {dueDate: string | nullestimatorId: string | nullexpirationDate: string | null+ externalNotes: Json | nullid: string+ internalNotes: Json | nulllocationId: string | null- notes: Json | nullquoteId: stringrevisionId: numbersalesPersonId: string | null@@ -12233,9 +12234,10 @@ export type Database = {dueDate?: string | nullestimatorId?: string | nullexpirationDate?: string | null+ externalNotes?: Json | nullid?: string+ internalNotes?: Json | nulllocationId?: string | null- notes?: Json | nullquoteId: stringrevisionId?: numbersalesPersonId?: string | null@@ -12256,9 +12258,10 @@ export type Database = {dueDate?: string | nullestimatorId?: string | nullexpirationDate?: string | null+ externalNotes?: Json | nullid?: string+ internalNotes?: Json | nulllocationId?: string | null- notes?: Json | nullquoteId?: stringrevisionId?: numbersalesPersonId?: string | null@@ -23842,12 +23845,13 @@ export type Database = {dueDate: string | nullestimatorId: string | nullexpirationDate: string | null+ externalNotes: Json | nullfavorite: boolean | nullid: string | null+ internalNotes: Json | nulllines: number | nulllocationId: string | nulllocationName: string | null- notes: Json | nullquoteId: string | nullrevisionId: number | nullsalesOrderId: string | null@@ -25031,12 +25035,12 @@ export type Database = {customFields: Json | nullemployeeId: string | nullexpirationDate: string | null+ externalNotes: Json | nullfavorite: boolean | nullid: string | nullinternalNotes: string | nulllocationId: string | nulllocationName: string | null- notes: Json | nullquoteId: string | nullrevisionId: number | nullrfqDate: string | nulldiff --git a/packages/database/supabase/migrations/20240823012655_rfq-quote-internal-notes.sql b/packages/database/supabase/migrations/20240823012655_rfq-quote-internal-notes.sqlindex e08820185d..f390b9489c 100644--- a/packages/database/supabase/migrations/20240823012655_rfq-quote-internal-notes.sql+++ b/packages/database/supabase/migrations/20240823012655_rfq-quote-internal-notes.sql@@ -1,2 +1,50 @@+DROP VIEW "salesRfqs";+ALTER TABLE "salesRfq"-RENAME COLUMN "notes" to "externalNotes";\ No newline at end of file+ DROP COLUMN "notes",+ ADD COLUMN "externalNotes" JSON DEFAULT '{}';+++CREATE OR REPLACE VIEW "salesRfqs" WITH(SECURITY_INVOKER=true) AS+ SELECT+ rfq.*,+ l."name" AS "locationName",+ opp."quoteId",+ opp."salesOrderId",+ EXISTS(SELECT 1 FROM "salesRfqFavorite" rf WHERE rf."rfqId" = rfq.id AND rf."userId" = auth.uid()::text) AS favorite+ FROM "salesRfq" rfq+ LEFT JOIN "location" l+ ON l.id = rfq."locationId"+ LEFT JOIN "opportunity" opp+ ON opp."salesRfqId" = rfq.id;+++DROP VIEW "quotes";++ALTER TABLE "quote"+ DROP COLUMN "notes",+ ADD COLUMN "externalNotes" JSON DEFAULT '{}',+ ADD COLUMN "internalNotes" JSON DEFAULT '{}';++CREATE OR REPLACE VIEW "quotes" WITH(SECURITY_INVOKER=true) AS+ SELECT+ q.*,+ l."name" AS "locationName",+ ql."lines",+ ql."completedLines",+ EXISTS(SELECT 1 FROM "quoteFavorite" pf WHERE pf."quoteId" = q.id AND pf."userId" = auth.uid()::text) AS favorite,+ opp."salesRfqId",+ opp."salesOrderId"+ FROM "quote" q+ LEFT JOIN (+ SELECT+ "quoteId",+ COUNT("id") AS "lines",+ COUNT("id") FILTER (WHERE "status" = 'Complete') AS "completedLines"+ FROM "quoteLine"+ GROUP BY "quoteId"+ ) ql ON ql."quoteId" = q.id+ LEFT JOIN "location" l+ ON l.id = q."locationId"+ LEFT JOIN "opportunity" opp+ ON opp."quoteId" = q.id;\ No newline at end of file