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): temp backwards compat for rename

Sidwebworksda891f6c270a
diff --git a/ci/src/migrations.ts b/ci/src/migrations.ts
index 08aa5cc501..6fe010c5c7 100644
--- a/ci/src/migrations.ts
+++ b/ci/src/migrations.ts
@@ -89,6 +89,22 @@ async function migrate(): Promise<void> {
console.log(`✅ 🐣 Starting migrations for ${workspace.id}`);
+ // TEMP backwards-compat shim — REMOVE once every workspace has deployed
+ // past this (then also delete the migration file). Migration `20260515`
+ // shipped with a non-standard 8-digit timestamp and was renamed to
+ // `20260515000000`. Workspaces that already recorded the old version hit a
+ // `db push` orphan gate ("Remote migration versions not found in local
+ // migrations directory") that blocks ALL their migrations. Marking the old
+ // version reverted touches the tracking table only (no SQL) and is a no-op
+ // on fresh workspaces that never had it; the renamed migration is
+ // idempotent (ADD COLUMN IF NOT EXISTS) so the push below re-applies it
+ // harmlessly.
+ const repairDbUrl =
+ connection_string && connection_string.startsWith("postgresql://")
+ ? ["--db-url", connection_string]
+ : [];
+ await $$`supabase migration repair --status reverted 20260515 ${repairDbUrl}`;
+
if (connection_string && connection_string.startsWith("postgresql://")) {
await $$`supabase db push --db-url ${connection_string} --include-all`;
} else {
diff --git a/packages/database/supabase/migrations/20260515_custom_rule_item_filters.sql b/packages/database/supabase/migrations/20260515000000_custom_rule_item_filters.sql
similarity index 65%
rename from packages/database/supabase/migrations/20260515_custom_rule_item_filters.sql
rename to packages/database/supabase/migrations/20260515000000_custom_rule_item_filters.sql
index 5fc1748f32..5bb4ef6d8d 100644
--- a/packages/database/supabase/migrations/20260515_custom_rule_item_filters.sql
+++ b/packages/database/supabase/migrations/20260515000000_custom_rule_item_filters.sql
@@ -7,6 +7,6 @@
-- otherwise the rule fires on items matching the selected types and/or groups
-- (`filteredItemMatchAll` chooses OR vs AND between the two dimensions).
ALTER TABLE "customRule"
- ADD COLUMN "filteredItemTypes" TEXT[] NOT NULL DEFAULT '{}',
- ADD COLUMN "filteredItemGroupIds" TEXT[] NOT NULL DEFAULT '{}',
- ADD COLUMN "filteredItemMatchAll" BOOLEAN NOT NULL DEFAULT false; -- false = OR (any), true = AND (all)
+ ADD COLUMN IF NOT EXISTS "filteredItemTypes" TEXT[] NOT NULL DEFAULT '{}',
+ ADD COLUMN IF NOT EXISTS "filteredItemGroupIds" TEXT[] NOT NULL DEFAULT '{}',
+ ADD COLUMN IF NOT EXISTS "filteredItemMatchAll" BOOLEAN NOT NULL DEFAULT false; -- false = OR (any), true = AND (all)