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.

Rename old non-conformance seed data on existing databases (#1640)

Sid1f1f2fa6bc71
diff --git a/packages/database/supabase/migrations/20260915192947_rename-non-conformance-seed-data.sql b/packages/database/supabase/migrations/20260915192947_rename-non-conformance-seed-data.sql
new file mode 100644
index 0000000000..2bda37fa42
--- /dev/null
+++ b/packages/database/supabase/migrations/20260915192947_rename-non-conformance-seed-data.sql
@@ -0,0 +1,32 @@
+-- PR #232 renamed non-conformances to issues by editing already-applied
+-- migrations (20250327140050_ncr.sql, 20250502132738_gauge-calibration.sql),
+-- so databases built before it still hold the old seeded names. Fresh
+-- databases already have the new names and every UPDATE here is a no-op.
+
+UPDATE "customFieldTable" SET "name" = 'Issue'
+WHERE "table" = 'nonConformance' AND "name" = 'Non-Conformance';
+
+UPDATE "customFieldTable" SET "name" = 'Issue Type'
+WHERE "table" = 'nonConformanceType' AND "name" = 'Non-Conformance Type';
+
+UPDATE "sequence" SET "name" = 'Issue'
+WHERE "table" = 'nonConformance' AND "name" = 'Non-Conformance';
+
+-- Guards match the "nonConformanceType_companyId_name_key" unique index on
+-- ("companyId", LOWER("name")): skip the rename where the user already
+-- created a type with the new name.
+UPDATE "nonConformanceType" SET "name" = 'Material Issue'
+WHERE "name" = 'Material Non-Conformance' AND "createdBy" = 'system'
+ AND NOT EXISTS (
+ SELECT 1 FROM "nonConformanceType" t
+ WHERE t."companyId" = "nonConformanceType"."companyId"
+ AND LOWER(t."name") = 'material issue'
+ );
+
+UPDATE "nonConformanceType" SET "name" = 'Supplier Issue'
+WHERE "name" = 'Supplier Non-Conformance' AND "createdBy" = 'system'
+ AND NOT EXISTS (
+ SELECT 1 FROM "nonConformanceType" t
+ WHERE t."companyId" = "nonConformanceType"."companyId"
+ AND LOWER(t."name") = 'supplier issue'
+ );
diff --git a/packages/jobs/manifests/schema.json b/packages/jobs/manifests/schema.json
index 049493d475..eba201a011 100644
--- a/packages/jobs/manifests/schema.json
+++ b/packages/jobs/manifests/schema.json
@@ -1,11 +1,11 @@
{
"kind": "carbon-company-backup",
"version": 1,
- "schemaVersion": "20260914095239",
+ "schemaVersion": "20260915192947",
"sourceCompanyId": "schema-baseline",
"sourceCompanyGroupId": null,
"sourceCompanyName": null,
- "exportedAt": "2026-09-15T18:44:34.921Z",
+ "exportedAt": "2026-09-15T19:41:29.579Z",
"exportedBy": "schema-baseline",
"label": "schema baseline",
"includeStorage": "none",
diff --git a/packages/jobs/src/scripts/check-backups.ts b/packages/jobs/src/scripts/check-backups.ts
index 0003aaf412..fdf77d6c42 100644
--- a/packages/jobs/src/scripts/check-backups.ts
+++ b/packages/jobs/src/scripts/check-backups.ts
@@ -213,6 +213,15 @@ function writeSchemaFile(catalog: Catalog): void {
const manifest = catalogAsManifest(catalog, now("UTC").toAbsoluteString());
mkdirSync(dirname(SCHEMA_FILE), { recursive: true });
writeFileSync(SCHEMA_FILE, `${JSON.stringify(manifest, null, 2)}\n`);
+ // lint-staged has already run by the time the pre-commit hook stages this file,
+ // so format it here or it never sees Biome at all.
+ try {
+ execFileSync("pnpm", ["exec", "biome", "format", "--write", SCHEMA_FILE], {
+ stdio: "pipe"
+ });
+ } catch {
+ // Cosmetic only — never block a commit on the formatter.
+ }
try {
git(["add", SCHEMA_FILE]);
console.log(