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(database): use DROP+CREATE for invoice dust views — fixes SQLSTATE 42P16 (#996)
Carbon Agent146262b8cb1b
diff --git a/packages/database/supabase/migrations/20260630151500_invoice-dust-forgiveness.sql b/packages/database/supabase/migrations/20260630151500_invoice-dust-forgiveness.sqlindex 8a62a1616f..415ac02523 100644--- a/packages/database/supabase/migrations/20260630151500_invoice-dust-forgiveness.sql+++ b/packages/database/supabase/migrations/20260630151500_invoice-dust-forgiveness.sql@@ -26,12 +26,22 @@-- ============================================================+-- ============================================================+-- Phase 1: Drop existing views+-- CREATE OR REPLACE VIEW cannot change column expression types+-- (e.g. simple column → CASE expression), so we must drop + recreate.+-- ============================================================++DROP VIEW IF EXISTS "salesInvoices";+DROP VIEW IF EXISTS "purchaseInvoices";++-- ============================================================-- salesInvoices — derived balance/status/datePaid with dust forgiveness-- Active state for sales invoices is 'Submitted'.-- ============================================================-CREATE OR REPLACE VIEW "salesInvoices" WITH(SECURITY_INVOKER=true) AS+CREATE VIEW "salesInvoices" WITH(SECURITY_INVOKER=true) ASWITH settled AS (SELECTpa."targetSalesInvoiceId",@@ -139,7 +149,7 @@ CREATE OR REPLACE VIEW "salesInvoices" WITH(SECURITY_INVOKER=true) AS-- Active state for purchase invoices is 'Open'.-- ============================================================-CREATE OR REPLACE VIEW "purchaseInvoices" WITH(SECURITY_INVOKER=true) AS+CREATE VIEW "purchaseInvoices" WITH(SECURITY_INVOKER=true) ASWITH settled AS (SELECTpa."targetPurchaseInvoiceId",