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.

fix: migration for cost ledger migration

Brad Barbin98d368e6d08d
diff --git a/packages/database/supabase/migrations/20250116182231_shipping-cost-on-purchase-order.sql b/packages/database/supabase/migrations/20250116182231_shipping-cost-on-purchase-order.sql
index 5516f0a74b..4866833d05 100644
--- a/packages/database/supabase/migrations/20250116182231_shipping-cost-on-purchase-order.sql
+++ b/packages/database/supabase/migrations/20250116182231_shipping-cost-on-purchase-order.sql
@@ -1,10 +1,9 @@
ALTER TABLE "purchaseOrderDelivery"
-ADD COLUMN "supplierShippingCost" NUMERIC NOT NULL DEFAULT 0;
+ADD COLUMN IF NOT EXISTS "supplierShippingCost" NUMERIC NOT NULL DEFAULT 0;
-ALTER TABLE "costLedger"
- RENAME COLUMN "costPostedToGL" TO "nominalCost",
- ADD COLUMN "supplierId" TEXT REFERENCES "supplier" ("id"),
- DROP COLUMN "itemReadableId";
+ALTER TABLE "costLedger" RENAME COLUMN "costPostedToGL" TO "nominalCost";
+ALTER TABLE "costLedger" ADD COLUMN "supplierId" TEXT REFERENCES "supplier" ("id");
+ALTER TABLE "costLedger" DROP COLUMN "itemReadableId";
INSERT INTO "customFieldTable" ("table", "name", "module")
VALUES ('purchaseInvoiceDelivery', 'Purchase Invoice Delivery', 'Purchase Orders');