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/mes animations in assembly view (#1607)
Anshul sharmaaba30176878a
diff --git a/.ai/plans/2026-09-10-assembly-version-activation-job-resync.md b/.ai/plans/2026-09-10-assembly-version-activation-job-resync.mdnew file mode 100644index 0000000000..1d7e71b9a7--- /dev/null+++ b/.ai/plans/2026-09-10-assembly-version-activation-job-resync.md@@ -0,0 +1,718 @@+# Assembly version activation — keep MES playback working on live jobs++**Spec / source:** `.ai/specs/2026-09-10-assembly-version-activation-job-resync.md`+**Branch:** `fix/mes-animations-in-assembly-view`++## Background for the executor++Activating a new assembly-instruction version repoints+`jobOperation.assemblyInstructionId` (v1 → v2) but never migrates+`jobOperationStep.assemblyInstructionStepId`. Each version's steps get **new+ids**, so job step markers still hold v1 ids. MES matches the animation frame by+exact id (`AssemblyView.tsx:1087`), gets `-1`, and falls back to a static model+slide on every step — the reported "animations are broken".++This plan: persist step lineage (`rootStepId`), remap markers on activation,+let re-sync reclaim orphaned steps, and backfill already-broken jobs.++## Progress+- [x] Task 1: Add `rootStepId` column + backfill migration+- [x] Task 2: Persist `rootStepId` in `copyAssemblyInstructionAsVersion`+- [x] Task 3: Add `planAssemblyStepMarkerRemap` pure helper + unit tests+- [x] Task 4: Let re-sync reclaim orphaned (null-marker) steps + unit tests+- [x] Task 5: Remap markers and re-sync in `activateAssemblyInstructionVersion`+- [x] Task 6: Typecheck, lint, and end-to-end verification++## Dependencies++- Task 2 needs Task 1 (column must exist before types regen).+- Task 3 is independent of Tasks 1–2 (pure function + tests) but its consumer is Task 5.+- Task 4 is independent of Tasks 1–3.+- Task 5 needs Tasks 1, 2, 3, 4.+- Task 6 needs all previous tasks.+- **Tasks 3 and 4 may run in parallel** once Task 1 is applied.++---++## Task 1: Add `rootStepId` column + backfill migration++**Depends on:** none++**Files:**+- Create: `packages/database/supabase/migrations/{generated}_assembly-step-lineage.sql`+- Copy from (precedent): `packages/database/supabase/migrations/20260720025847_assembly-bop-sync.sql`++**Steps:**++1. Create the migration file:+ ```bash+ pnpm db:migrate:new assembly-step-lineage+ ```+ This prints the created path. **Do not** hand-write the timestamp; never use+ `000000` for HHMMSS (per `packages/database/AGENTS.md`).++2. Write exactly this SQL into the created file:++```sql+-- Assembly step lineage: links a step to the step it was copied from when a new+-- instruction version is created. Mirrors the instruction-level+-- "rootInstructionId" idiom — NULL means "I am the root", so a step's lineage+-- group is COALESCE("rootStepId", "id") (same shape as+-- 20260730153412_assembly-instructions-view.sql).+--+-- ON DELETE SET NULL: deleting an OLD version must never delete the CURRENT+-- version's steps; an orphaned step simply becomes its own root.++ALTER TABLE "assemblyInstructionStep"+ ADD COLUMN IF NOT EXISTS "rootStepId" TEXT+ REFERENCES "assemblyInstructionStep"("id") ON DELETE SET NULL;++CREATE INDEX IF NOT EXISTS "assemblyInstructionStep_rootStepId_idx"+ ON "assemblyInstructionStep" ("rootStepId");++-- Backfill: repair job step markers stranded on a NON-CURRENT instruction+-- version by an activation that repointed the operation but not its steps.+-- rootStepId cannot exist retroactively, so match within the version group by+-- title first, then by sortOrder. Idempotent: the WHERE clause only selects+-- markers that disagree with their operation's instruction, so a second run+-- matches nothing.+WITH stranded AS (+ SELECT+ s."id" AS "jobStepId",+ s."companyId" AS "companyId",+ jo."assemblyInstructionId" AS "currentInstructionId",+ old."title" AS "title",+ old."sortOrder" AS "sortOrder"+ FROM "jobOperationStep" s+ JOIN "assemblyInstructionStep" old+ ON old."id" = s."assemblyInstructionStepId"+ JOIN "jobOperation" jo+ ON jo."id" = s."operationId"+ WHERE jo."assemblyInstructionId" IS NOT NULL+ AND old."assemblyInstructionId" <> jo."assemblyInstructionId"+),+matched AS (+ SELECT+ st."jobStepId",+ (+ SELECT nw."id"+ FROM "assemblyInstructionStep" nw+ WHERE nw."assemblyInstructionId" = st."currentInstructionId"+ AND nw."companyId" = st."companyId"+ ORDER BY+ (nw."title" IS NOT DISTINCT FROM st."title") DESC,+ (nw."sortOrder" IS NOT DISTINCT FROM st."sortOrder") DESC,+ nw."sortOrder" ASC+ LIMIT 1+ ) AS "newStepId"+ FROM stranded st+)+UPDATE "jobOperationStep" s+SET "assemblyInstructionStepId" = m."newStepId"+FROM matched m+WHERE s."id" = m."jobStepId"+ AND m."newStepId" IS NOT NULL;+```++3. Apply it (this also regenerates `packages/database/src/types.ts`):+ ```bash+ pnpm db:migrate+ ```++**Verify:**+```bash+docker exec -e PGPASSWORD="$(grep '^SUPABASE_DB_URL' .env.local | sed -E 's|.*://postgres:([^@]*)@.*|\1|')" \+ carbon-carbon-fix-mes-animations-in-assembly-view-postgres-1 \+ psql -U postgres -d postgres -c \+ 'select column_name from information_schema.columns where table_name = '"'"'assemblyInstructionStep'"'"' and column_name = '"'"'rootStepId'"'"';'+# Expected: one row, "rootStepId"++grep -c 'rootStepId' packages/database/src/types.ts+# Expected: a number >= 1 (types regenerated by pnpm db:migrate)+```++Then confirm the backfill repaired the known-broken operation:+```bash+docker exec -e PGPASSWORD="$(grep '^SUPABASE_DB_URL' .env.local | sed -E 's|.*://postgres:([^@]*)@.*|\1|')" \+ carbon-carbon-fix-mes-animations-in-assembly-view-postgres-1 \+ psql -U postgres -d postgres -c \+ 'select count(*) as still_stranded from "jobOperationStep" s join "assemblyInstructionStep" ais on ais.id = s."assemblyInstructionStepId" join "jobOperation" jo on jo.id = s."operationId" where jo."assemblyInstructionId" is not null and ais."assemblyInstructionId" <> jo."assemblyInstructionId";'+# Expected: still_stranded = 0+```++**Out of scope:** Do NOT change the `ON DELETE SET NULL` on the existing+`assemblyInstructionStepId` FK (`20260720025847_assembly-bop-sync.sql:18`) — the+spec keeps that semantics deliberately. Do NOT add RLS policies (no new table).+Do NOT backfill `NULL` markers (explicitly out of scope per spec §4).++**If** `pnpm db:migrate` fails because the local DB is unreachable, STOP and+report — do not hand-apply SQL to work around it.++---++## Task 2: Persist `rootStepId` in `copyAssemblyInstructionAsVersion`++**Depends on:** Task 1++**Files:**+- Modify: `apps/erp/app/modules/production/production.service.ts` — set `rootStepId` on copied steps++**Steps:**++1. In `copyAssemblyInstructionAsVersion` (starts line ~6358), find the step-copy+ block that currently reads:++```ts+ const stepRows = sourceSteps.data.map((step) => {+ // Strip identity/audit columns; keep every authored field verbatim.+ // biome-ignore lint/correctness/noUnusedVariables: destructure omits identity/audit columns before re-insert+ const { id, createdAt, updatedAt, updatedBy, ...rest } = step;+ return {+ ...rest,+ id: stepIdMap.get(step.id)!,+ assemblyInstructionId: newInstructionId,+ parentStepId: step.parentStepId+ ? (stepIdMap.get(step.parentStepId) ?? null)+ : null,+ companyId,+ createdBy: userId+ };+ });+```++2. Add `rootStepId` to the returned object, immediately after the+ `parentStepId` property:++```ts+ // Lineage across versions: a step copied from v1 roots at v1's step, and+ // a v3 copied from v2 still roots at v1 — the chain stays flat so+ // COALESCE("rootStepId", "id") identifies the group at any depth.+ rootStepId: step.rootStepId ?? step.id,+```++**Verify:**+```bash+pnpm --filter erp typecheck+# Expected: no errors (exit 0). rootStepId must be a known column — if TS says it+# is not, Task 1's type regen did not run.+```++**Out of scope:** Do NOT change how `parentStepId` is remapped, the version+numbering, or the `status: "Draft"` of the new version.++**If** `step.rootStepId` is a TypeScript error, STOP and report — it means+Task 1's `pnpm db:migrate` did not regenerate types.++---++## Task 3: Add `planAssemblyStepMarkerRemap` pure helper + unit tests++**Depends on:** none (may run in parallel with Task 4)++**Files:**+- Modify: `apps/erp/app/modules/production/production.service.ts` — add exported pure function+- Modify: `apps/erp/app/modules/production/production.service.test.ts` — add tests+- Copy from (precedent): `planAssemblyStepMarkerSync` (`production.service.ts:8022`) and its tests (`production.service.test.ts:38`)++**Steps:**++1. Add this exported pure function directly **above**+ `planAssemblyStepMarkerSync` (line ~8022), matching that function's+ doc-comment style:++```ts+/**+ * Maps a job step's marker from an OLD instruction version's step id to the+ * equivalent step id in the NEWLY-ACTIVATED version, by lineage group+ * (COALESCE(rootStepId, id) — the same idiom as rootInstructionId).+ *+ * A step that survives across versions keeps its identity even when reordered+ * or retitled, so the caller can UPDATE it in place and preserve the operator's+ * completion records. Steps with no counterpart in the new version are left+ * unmapped — the caller's re-sync then treats them as stale. Pure so the+ * remapping is unit-testable.+ */+export function planAssemblyStepMarkerRemap(+ oldSteps: { id: string; rootStepId: string | null }[],+ newSteps: { id: string; rootStepId: string | null }[]+): Map<string, string> {+ const newIdByRoot = new Map<string, string>();+ for (const step of newSteps) {+ const root = step.rootStepId ?? step.id;+ // First writer wins: a well-formed version has one step per lineage group.+ if (!newIdByRoot.has(root)) newIdByRoot.set(root, step.id);+ }++ const remap = new Map<string, string>();+ for (const step of oldSteps) {+ const root = step.rootStepId ?? step.id;+ const newId = newIdByRoot.get(root);+ if (newId && newId !== step.id) remap.set(step.id, newId);+ }+ return remap;+}+```++2. Export it from the module barrel if `planAssemblyStepMarkerSync` is exported+ there. Check first:+ ```bash+ grep -n "planAssemblyStepMarkerSync" apps/erp/app/modules/production/index.ts+ ```+ If it appears, add `planAssemblyStepMarkerRemap` alongside it in the same+ style. If it does not appear, skip this step (the function is imported+ directly from the service file by the test).++3. Add tests to `production.service.test.ts`. Import+ `planAssemblyStepMarkerRemap` alongside the existing+ `planAssemblyStepMarkerSync` import (line ~31), then add this `describe`+ block immediately after the existing `planAssemblyStepMarkerSync` block+ (which ends around line 71):++```ts+describe("planAssemblyStepMarkerRemap", () => {+ it("maps a v1 step id to the v2 step copied from it", () => {+ const remap = planAssemblyStepMarkerRemap(+ [{ id: "v1a", rootStepId: null }],+ [{ id: "v2a", rootStepId: "v1a" }]+ );+ expect(remap.get("v1a")).toBe("v2a");+ });++ it("maps across three versions via the flat root chain", () => {+ // v3 copied from v2 still roots at v1.+ const remap = planAssemblyStepMarkerRemap(+ [{ id: "v2a", rootStepId: "v1a" }],+ [{ id: "v3a", rootStepId: "v1a" }]+ );+ expect(remap.get("v2a")).toBe("v3a");+ });++ it("maps regardless of reordering", () => {+ const remap = planAssemblyStepMarkerRemap(+ [+ { id: "v1a", rootStepId: null },+ { id: "v1b", rootStepId: null }+ ],+ [+ { id: "v2b", rootStepId: "v1b" },+ { id: "v2a", rootStepId: "v1a" }+ ]+ );+ expect(remap.get("v1a")).toBe("v2a");+ expect(remap.get("v1b")).toBe("v2b");+ });++ it("leaves a deleted step unmapped", () => {+ const remap = planAssemblyStepMarkerRemap(+ [+ { id: "v1a", rootStepId: null },+ { id: "v1gone", rootStepId: null }+ ],+ [{ id: "v2a", rootStepId: "v1a" }]+ );+ expect(remap.get("v1a")).toBe("v2a");+ expect(remap.has("v1gone")).toBe(false);+ });++ it("ignores a step added in the new version", () => {+ const remap = planAssemblyStepMarkerRemap(+ [{ id: "v1a", rootStepId: null }],+ [+ { id: "v2a", rootStepId: "v1a" },+ { id: "v2new", rootStepId: null }+ ]+ );+ expect(remap.size).toBe(1);+ });++ it("does not map a step to itself", () => {+ const remap = planAssemblyStepMarkerRemap(+ [{ id: "same", rootStepId: null }],+ [{ id: "same", rootStepId: null }]+ );+ expect(remap.size).toBe(0);+ });+});+```++**Verify:**+```bash+pnpm --filter erp exec vitest run app/modules/production/production.service.test.ts -t "planAssemblyStepMarkerRemap"+# Expected: 6 passed, 0 failed+```++**Out of scope:** Do NOT modify `planAssemblyStepMarkerSync` or its existing+tests in this task (Task 4 handles the sync change).++---++## Task 4: Let re-sync reclaim orphaned (null-marker) steps++**Depends on:** none (may run in parallel with Task 3)++**Files:**+- Modify: `apps/erp/app/modules/production/production.service.ts` — `syncAssemblyInstructionToOperation` (line ~8088)+- Modify: `apps/erp/app/modules/production/production.service.test.ts` — add tests++**Context:** the query at line ~8215 currently loads only marked steps:++```ts+ const existingSynced = await trx+ .selectFrom(stepTable)+ .select(["id", "assemblyInstructionStepId"])+ .where("operationId", "=", operationId)+ .where("companyId", "=", companyId)+ .where("assemblyInstructionStepId", "is not", null)+ .execute();+```++Steps orphaned by the `ON DELETE SET NULL` cascade have a NULL marker, look+"hand-authored", and are never reclaimed — so a re-sync inserts duplicates+beside them (observed: 10 broken + 10 new = 20 steps).++**Steps:**++1. Add this exported pure helper directly **above**+ `planAssemblyStepMarkerSync`:++```ts+/**+ * Re-adopts job steps orphaned by the assemblyInstructionStepId ON DELETE SET+ * NULL cascade (deleting an instruction step nulls the marker on every live+ * job synced from it). Without this a re-sync treats them as hand-authored and+ * inserts duplicates beside them.+ *+ * Deliberately conservative: an orphan is claimed only when it matches a source+ * step on BOTH sortOrder and name AND no already-marked step claims that source+ * step. Genuinely hand-authored steps match no source step and are untouched;+ * ambiguous cases are left alone rather than guessed at.+ */+export function planOrphanStepAdoption(+ sourceSteps: { id: string; title: string | null; sortOrder: number | null }[],+ orphanSteps: { id: string; name: string | null; sortOrder: number | null }[],+ claimedSourceIds: Set<string>+): Map<string, string> {+ const adoption = new Map<string, string>();+ const takenOrphans = new Set<string>();++ for (const source of sourceSteps) {+ if (claimedSourceIds.has(source.id)) continue;+ const match = orphanSteps.find(+ (orphan) =>+ !takenOrphans.has(orphan.id) &&+ orphan.sortOrder === source.sortOrder &&+ orphan.name === source.title+ );+ if (match) {+ adoption.set(match.id, source.id);+ takenOrphans.add(match.id);+ }+ }+ return adoption;+}+```++2. In `syncAssemblyInstructionToOperation`, replace the `existingSynced` query+ above with a version that also loads orphans, then adopts them **before**+ `planAssemblyStepMarkerSync` runs:++```ts+ const existingSteps = await trx+ .selectFrom(stepTable)+ .select(["id", "assemblyInstructionStepId", "name", "sortOrder"])+ .where("operationId", "=", operationId)+ .where("companyId", "=", companyId)+ .execute();++ const existingSynced = existingSteps.filter(+ (step) => step.assemblyInstructionStepId !== null+ );++ // Re-adopt steps orphaned by the ON DELETE SET NULL cascade so a re-sync+ // heals them instead of inserting duplicates beside them.+ const adoption = planOrphanStepAdoption(+ sourceSteps.map((step) => ({+ id: step.id,+ title: step.title,+ sortOrder: step.sortOrder+ })),+ existingSteps+ .filter((step) => step.assemblyInstructionStepId === null)+ .map((step) => ({+ id: step.id,+ name: step.name,+ sortOrder: step.sortOrder+ })),+ new Set(+ existingSynced+ .map((step) => step.assemblyInstructionStepId)+ .filter((id): id is string => id !== null)+ )+ );++ for (const [orphanId, sourceStepId] of adoption) {+ await trx+ .updateTable(stepTable)+ .set({ assemblyInstructionStepId: sourceStepId })+ .where("id", "=", orphanId)+ .where("companyId", "=", companyId)+ .execute();+ existingSynced.push({+ id: orphanId,+ assemblyInstructionStepId: sourceStepId,+ name: null,+ sortOrder: null+ });+ }+```++ Keep the immediately-following `planAssemblyStepMarkerSync(...)` call+ unchanged — it now receives the adopted steps in `existingSynced`.++3. Add tests to `production.service.test.ts`, after the+ `planAssemblyStepMarkerRemap` block:++```ts+describe("planOrphanStepAdoption", () => {+ it("adopts an orphan matching a source step on sortOrder and name", () => {+ const adoption = planOrphanStepAdoption(+ [{ id: "src1", title: "Fit cover", sortOrder: 1 }],+ [{ id: "orphan1", name: "Fit cover", sortOrder: 1 }],+ new Set()+ );+ expect(adoption.get("orphan1")).toBe("src1");+ });++ it("ignores an orphan whose name differs", () => {+ const adoption = planOrphanStepAdoption(+ [{ id: "src1", title: "Fit cover", sortOrder: 1 }],+ [{ id: "handmade", name: "Operator note", sortOrder: 1 }],+ new Set()+ );+ expect(adoption.size).toBe(0);+ });++ it("does not claim a source step an existing marked step already owns", () => {+ const adoption = planOrphanStepAdoption(+ [{ id: "src1", title: "Fit cover", sortOrder: 1 }],+ [{ id: "orphan1", name: "Fit cover", sortOrder: 1 }],+ new Set(["src1"])+ );+ expect(adoption.size).toBe(0);+ });++ it("adopts each orphan at most once", () => {+ const adoption = planOrphanStepAdoption(+ [+ { id: "src1", title: "Same", sortOrder: 1 },+ { id: "src2", title: "Same", sortOrder: 1 }+ ],+ [{ id: "orphan1", name: "Same", sortOrder: 1 }],+ new Set()+ );+ expect(adoption.size).toBe(1);+ });+});+```++**Verify:**+```bash+pnpm --filter erp exec vitest run app/modules/production/production.service.test.ts+# Expected: all tests pass, including the pre-existing planAssemblyStepMarkerSync,+# maxToolQuantityByItem, buildAssemblyToolStepLinks and duplicateJobOperationStep suites+```++**Out of scope:** Do NOT change `planAssemblyStepMarkerSync`'s own logic, the+stale-step deletion, or the material/tool link rebuild.++---++## Task 5: Remap markers and re-sync in `activateAssemblyInstructionVersion`++**Depends on:** Tasks 1, 2, 3, 4++**Files:**+- Modify: `apps/erp/app/modules/production/production.service.ts` — `activateAssemblyInstructionVersion` (line ~6488)++**Context:** the function currently ends its repoint block like this (line ~6563):++```ts+ const staleOpIds = (staleOps.data ?? []).map((o) => o.id);+ if (staleOpIds.length > 0) {+ const repoint = await client+ .from("jobOperation")+ .update({ assemblyInstructionId: id })+ .in("id", staleOpIds);+ if (repoint.error) return repoint;+ }+ }++ return publish;+}+```++**Steps:**++1. Immediately **after** the `repoint` block and before the closing `}` of the+ `if (otherVersionIds.length > 0)` block, add the marker remap. Load both+ versions' steps once (bounded by the sibling-version set, not by job count —+ preserving the existing 1000-row-cap reasoning documented at line ~6548):++```ts+ // Migrate step markers v(old) -> v(new) by lineage group before syncing.+ // Without this the job's steps still point at the old version's step ids,+ // MES cannot match them (AssemblyView findIndex -> -1), and playback+ // silently degrades to a static model on every step.+ const [oldStepRows, newStepRows] = await Promise.all([+ client+ .from("assemblyInstructionStep")+ .select("id, rootStepId")+ .in("assemblyInstructionId", otherVersionIds)+ .eq("companyId", companyId),+ client+ .from("assemblyInstructionStep")+ .select("id, rootStepId")+ .eq("assemblyInstructionId", id)+ .eq("companyId", companyId)+ ]);+ if (oldStepRows.error) return oldStepRows;+ if (newStepRows.error) return newStepRows;++ const remap = planAssemblyStepMarkerRemap(+ oldStepRows.data ?? [],+ newStepRows.data ?? []+ );++ for (const [oldStepId, newStepId] of remap) {+ const remapped = await client+ .from("jobOperationStep")+ .update({ assemblyInstructionStepId: newStepId })+ .eq("assemblyInstructionStepId", oldStepId)+ .eq("companyId", companyId)+ .in("operationId", staleOpIds);+ if (remapped.error) return remapped;+ }+```++2. After the remap loop (still inside the same block), re-sync each repointed+ operation so added steps appear and deleted steps are removed. One failure+ must not abort activation or leave other operations half-migrated:++```ts+ // Re-sync each repointed operation: marker-matched steps UPDATE in place+ // (so jobOperationStepRecord survives), steps added in the new version+ // INSERT, and steps deleted in it are removed. Isolated per operation so+ // one failure cannot abort the activation.+ for (const operationId of staleOpIds) {+ try {+ await syncAssemblyInstructionToOperation(getDatabaseClient(), {+ assemblyInstructionId: id,+ operationId,+ companyId,+ userId+ });+ } catch {+ // The marker remap above already restored playback for surviving+ // steps; a failed re-sync only leaves added/deleted steps unreconciled+ // on this one operation, and the user can re-sync it from the job.+ }+ }+```++3. **CORRECTED (escape hatch triggered during execution).** Do NOT import+ `getDatabaseClient` into `production.service.ts`. That is forbidden by+ `AGENTS.md:33` and enforced by the `no-db-client-in-service` conformance+ check (`@carbon/checks`): this service file is re-exported through the module+ barrel that client components import, so it is bundled for the browser and+ must not pull in `pg`/`kysely`. See the comment at+ `production.service.ts:991`.++ Instead follow the established pattern — the route action builds the client+ and passes it in:++ a. Add a `db: Kysely<KyselyDatabase>` parameter to+ `activateAssemblyInstructionVersion`'s args object (both types are already+ imported at the top of the service file).++ b. In the re-sync loop, call+ `syncAssemblyInstructionToOperation(db, { ... })` using that parameter.++ c. Update the only caller,+ `apps/erp/app/routes/x+/assembly+/$id.activate.tsx`, to pass+ `db: getDatabaseClient()`, importing it the same way+ `apps/erp/app/routes/x+/assembly+/$id.sync-bop.tsx` does.++**Verify:**+```bash+pnpm --filter erp typecheck+# Expected: no errors (exit 0)++pnpm --filter erp exec vitest run app/modules/production/production.service.test.ts+# Expected: all tests pass+```++**Out of scope:** Do NOT change the `staleOps` query's filters — it already+excludes `Done`/`Canceled` operations and locked jobs, and its bounded shape is+deliberate. Do NOT change the archive/publish ordering above it.++**If** `syncAssemblyInstructionToOperation` cannot be called with+`getDatabaseClient()` from this file (e.g. an import cycle), STOP and report —+do not duplicate the sync logic inline.++---++## Task 6: Typecheck, lint, and end-to-end verification++**Depends on:** Tasks 1–5++**Files:** none (verification only)++**Steps:**++1. Run the scoped typechecks and lint:++```bash+pnpm exec turbo run typecheck --filter=erp --filter=mes --filter=@carbon/database+pnpm run lint+```++2. Reset the local test fixture to a known-good synced state, then verify the+ activation path end to end in the UI. Current fixture (from the diagnosis):+ instruction v1 `dah6hsp0o0gg43i9reg0` (Archived), v2 `dah77qp0o0ghngq9reug`+ (Published), operation `jo_WrkvKZyRGCq3D79aBAWvjj` on job `J000009`.++ a. In the ERP, open the job's Bill of Process → the Assembly operation →+ **Sync Assembly Steps**. Confirm the step count does **not** double+ (acceptance criterion 6).++ b. Open MES at `/x/assembly/jo_WrkvKZyRGCq3D79aBAWvjj`. Confirm the `▶ 3D`+ playback slot and the transport bar are present and stepping advances the+ animation (acceptance criterion 1).++ c. In MES, mark one middle step done. Note which step.++ d. In the ERP, create a new version of the instruction, **reorder** steps and+ **delete** one (not the one marked done), then activate it.++ e. Reload MES. Confirm: playback still works (criterion 1); the step marked+ done in (c) is still marked done (criterion 2); the deleted step is gone+ (criterion 3); any added step appears in `sortOrder` position (criterion 4).++3. Confirm no operation is left stranded:++```bash+docker exec -e PGPASSWORD="$(grep '^SUPABASE_DB_URL' .env.local | sed -E 's|.*://postgres:([^@]*)@.*|\1|')" \+ carbon-carbon-fix-mes-animations-in-assembly-view-postgres-1 \+ psql -U postgres -d postgres -c \+ 'select count(*) as stranded from "jobOperationStep" s join "assemblyInstructionStep" ais on ais.id = s."assemblyInstructionStepId" join "jobOperation" jo on jo.id = s."operationId" where jo."assemblyInstructionId" is not null and ais."assemblyInstructionId" <> jo."assemblyInstructionId";'+# Expected: stranded = 0+```++**Verify:** all commands above exit 0, and steps 2(a)–2(e) match the stated+expectations.++**Out of scope:** Do NOT commit. The user's standing rule is that nothing is+committed without explicit permission — report completion and wait.++**If** any acceptance criterion fails, STOP and report which one with the+observed behaviour — do not patch around it.diff --git a/.ai/specs/2026-09-10-assembly-version-activation-job-resync.md b/.ai/specs/2026-09-10-assembly-version-activation-job-resync.mdnew file mode 100644index 0000000000..69d15f1db7--- /dev/null+++ b/.ai/specs/2026-09-10-assembly-version-activation-job-resync.md@@ -0,0 +1,264 @@+# Assembly instruction version activation — keep MES playback working on live jobs++Status: Approved (2026-09-10)++## Problem++Activating a new version of an assembly instruction silently breaks the animated+3D playback in MES for every in-flight job using that instruction. The operator+sees a static full 3D model on every step — no animation, no transport bar, no+playback slot — and reasonably reports "the MES animations are broken".++Reported by a customer against `SA-0076`; reproduced end-to-end locally.++### Root cause++`activateAssemblyInstructionVersion` (`apps/erp/app/modules/production/production.service.ts:6488`)+repoints in-flight work to the newly-activated version:++```+jobOperation.assemblyInstructionId v1 -> v2 ✅ (line ~6564)+jobOperationStep.assemblyInstructionStepId ❌ never migrated+```++Each version is a **new** `assemblyInstruction` row whose steps get **new ids**+(`copyAssemblyInstructionAsVersion:6413`, `nanoid()` per step). So after+activation the job's operation points at v2 while its step markers still hold+v1 step ids.++MES resolves the animation frame by exact id match+(`apps/mes/app/components/AssemblyView.tsx:1087`):++```ts+assemblyPlayback.steps.findIndex((s) => s.id === step.assemblyInstructionStepId)+```++v2's ids never match v1's markers → `findIndex` returns `-1` → `playbackIndex`+null → `playbackAvailable` false. The per-step **model slide** survives (slides+hang off `modelUpload`, which nothing touched), so the panel falls through to+that slide — an orbitable but static full model, identical on every step.++Verified in the DB: op `jo_WrkvKZyRGCq3D79aBAWvjj` points at v2+`dah77qp0o0ghngq9reug` while all 10 of its markers belong to v1+`dah6hsp0o0gg43i9reg0`.++### Secondary cause (same symptom, different route)++The marker FK is `ON DELETE SET NULL`+(`packages/database/supabase/migrations/20260720025847_assembly-bop-sync.sql:18`).+Deleting instruction steps nulls markers on every live job synced from them.++This is compounded by the sync's own filter+(`production.service.ts:8220`):++```ts+.where("assemblyInstructionStepId", "is not", null)+```++Null-marker steps are treated as **hand-authored** and are therefore never+reclaimed. A user trying to self-heal by clicking "Sync Assembly Steps" gets a+**duplicate** set of steps inserted alongside the broken ones (observed: 10+broken + 10 new = 20 steps, ~half animating, colliding on `sortOrder` and+sharing names).++### Scope of impact++- Only **in-flight** work breaks. Activation's repoint query already excludes+ `Done`/`Canceled` operations and locked jobs, so completed jobs are unaffected.+- Editing a step's *text* is harmless. Breakage requires steps to be **added,+ reordered, or deleted** in the new version — anything that changes the id set.+- Latent since `cb69865131` (2026-07-27), which shipped both the marker column+ and the MES playback feature. Not a recent regression; it requires an+ instruction to be versioned while jobs are live.++## Goals++1. Activating a new version keeps MES playback working on every in-flight job.+2. A step that survives v1→v2 keeps its identity **and** its operator completion+ records, even when reordered or retitled.+3. A user who is already broken can self-heal with "Sync Assembly Steps" without+ producing duplicates.+4. Jobs already broken by this bug are repaired automatically where possible.++## Non-goals++- Changing the `ON DELETE SET NULL` FK semantics. The migration's intent —+ demoting synced steps to hand-authored rather than destroying operator work —+ stays. We fix the *consequence* (unreclaimable orphans), not the cascade.+- Re-planning motion/camera, or any assembler/model-pipeline change.+- Versioning `methodOperationStep` markers (BOP templates). Out of scope; only+ job-side playback is affected.+- Preventing activation while jobs are in flight (rejected: activation is the+ intended way to roll a change out to the floor).++## Design++### 1. Persist step provenance across versions++`copyAssemblyInstructionAsVersion` already builds the exact v1→v2 correspondence+(`stepIdMap`, line 6413) and **discards** it. Persist it, mirroring the existing+instruction-level `rootInstructionId` idiom.++```+assemblyInstructionStep+ + rootStepId TEXT NULL REFERENCES "assemblyInstructionStep"("id") ON DELETE SET NULL+ + index on ("rootStepId")+```++Semantics match `rootInstructionId` exactly: `NULL` means "I am the root", so a+step's group root is `COALESCE("rootStepId", "id")` — the same+`COALESCE(rootInstructionId, id)` pattern already used in+`20260730153412_assembly-instructions-view.sql`.++`ON DELETE SET NULL` (not CASCADE): deleting an old version must never delete+the current version's steps. A v2 step whose v1 ancestor is deleted simply+becomes its own root.++On copy: `rootStepId = source.rootStepId ?? source.id`. Chains stay flat, so v3+copied from v2 still roots at v1 and lineage survives arbitrarily many versions.++### 2. Remap job markers on activation++After the existing repoint in `activateAssemblyInstructionVersion`, migrate each+affected operation's step markers from the old version's step ids to the new+version's, matching on group root:++```+old marker -> COALESCE(old.rootStepId, old.id) == COALESCE(new.rootStepId, new.id) -> new marker+```++Outcomes per step, which follow directly from the resolved questions:++| Case | Action | Completion records |+|---|---|---|+| Step survives v1→v2 (even reordered/retitled) | `UPDATE` marker + payload | **Preserved** |+| Step added in v2 | `INSERT` | N/A |+| Step deleted in v2 | `DELETE` | Lost (approved — deleted steps just disappear) |++Reuse `syncAssemblyInstructionToOperation` (line 8088) rather than reimplementing+reconciliation; it already updates matched steps, inserts new ones, and deletes+stale ones, and its matched-step path is an `UPDATE`, so+`jobOperationStepRecord` (FK `ON DELETE CASCADE`, verified) survives. The marker+remap runs **before** the sync so the sync sees v2-space markers and matches+them.++Bounded-query property: the existing stale-op lookup is deliberately driven off+`jobOperation` to avoid a 1000-row cap (see the comment at ~6548). Preserve it —+remap and sync per repointed op id, never by first materializing every job.++Failure isolation: one operation failing to sync must not abort the activation+or leave other operations half-migrated. Activation reports how many operations+were resynced and how many failed.++### 3. Let re-sync reclaim orphaned steps++Relax the "hand-authored" assumption at `production.service.ts:8220` so a+re-sync can re-adopt steps orphaned by the `ON DELETE SET NULL` cascade, instead+of inserting duplicates beside them.++Adoption is deliberately conservative — a null-marker step is only re-adopted+when it is unambiguously a former synced step of *this* instruction:++- match by `sortOrder` **and** `name` against a source step, and+- only when no already-marked step claims that source step.++Genuinely hand-authored steps (which match no source step) keep today's+behaviour and are left untouched. Ambiguous matches are left alone rather than+guessed at.++### 4. Backfill already-broken jobs++A migration repairs markers stranded on a non-current version. Detector (already+validated against the local DB, returns the 1 known broken op):++```sql+FROM "jobOperationStep" s+JOIN "assemblyInstructionStep" ais ON ais.id = s."assemblyInstructionStepId"+JOIN "jobOperation" jo ON jo.id = s."operationId"+WHERE ais."assemblyInstructionId" <> jo."assemblyInstructionId"+```++Because `rootStepId` did not exist for rows created before this change, the+backfill is **best-effort** and matches within the version group by `title`,+then by `sortOrder`:++- matched → `UPDATE` the marker to the current version's step id (records kept)+- unmatched → left as-is; a "Sync Assembly Steps" in the UI finishes the repair+ (now safe, per §3)++The migration is idempotent and touches only rows the detector returns. Jobs+whose markers are `NULL` (the FK-cascade route) are not in scope for the+backfill — §3 makes those repairable from the UI.++### UI / copy++No new screens. Activation already reports success via a flash message; extend+it to mention the number of in-flight jobs resynced. All new user-facing copy is+Lingui-translatable (`t`/`<Trans>`), per project convention.++## Design decisions++| Decision | Choice | Rationale |+|---|---|---|+| Marker remap strategy | Add `rootStepId` provenance column | The exact map already exists at copy time and is thrown away. Only option that preserves completion records for surviving steps under reorder/retitle. |+| Provenance column shape | `rootStepId`, `COALESCE(root, id)` | Mirrors existing `rootInstructionId` idiom, incl. the view at `20260730153412`. No foreign idiom. |+| Provenance FK on delete | `SET NULL` | Deleting an old version must not delete current steps; orphaned step becomes its own root. |+| Chain shape across v3+ | Flat (`source.rootStepId ?? source.id`) | Lineage survives arbitrarily many versions without recursive resolution. |+| Reconciliation engine | Reuse `syncAssemblyInstructionToOperation` | Already handles update/insert/delete-stale correctly; matched path is `UPDATE`, so records survive. Constraint: reuse, don't reinvent. |+| Deleted-step records | Deleted with the step (cascade) | Explicit user ruling: "if a step is deleted, we don't show it in the end." |+| Orphan re-adoption | `sortOrder` + `name`, unclaimed only | Fixes the duplicate-steps trap without mis-attributing genuinely hand-authored steps. |+| Backfill matching | `title`, then `sortOrder` | `rootStepId` cannot exist retroactively; best-effort with UI re-sync as the completion path. |+| Backfill of NULL markers | Out of scope | §3 makes them self-healable; guessing their lineage is unreliable. |+| FK `ON DELETE SET NULL` | Unchanged | Original intent (preserve operator work) is sound; we fix the unreclaimable-orphan consequence instead. |++## Acceptance criteria++1. Given a job whose operation is synced to instruction v1 with 10 steps, when a+ v2 is created that reorders steps and deletes one, and v2 is activated, then+ opening `/x/assembly/{operationId}` in MES shows the `▶ 3D` playback slot and+ the transport bar, and stepping through advances the animation.+2. Given an operator has completed step 3 of 10, when a v2 that retitles and+ reorders (but does not delete) step 3 is activated, then that step's+ completion record still exists and shows as done in MES.+3. Given a v2 deletes a step the operator had completed, when v2 is activated,+ then that step no longer appears on the job and its record is gone.+4. Given a v2 adds a step, when v2 is activated, then the new step appears on the+ job in its correct `sortOrder`, unmarked as done.+5. Given a job locked or an operation `Done`/`Canceled`, when a version is+ activated, then that operation's steps are not modified.+6. Given a job whose markers were nulled by deleting instruction steps, when the+ user clicks "Sync Assembly Steps", then the orphaned steps are re-adopted and+ the total step count does **not** double.+7. Given the pre-existing broken op `jo_WrkvKZyRGCq3D79aBAWvjj` (markers on+ archived v1, op on v2), when the backfill migration runs, then its markers+ point at v2 steps and MES playback works without any UI action.+8. Running the backfill migration twice produces no additional changes.+9. `pnpm exec turbo run typecheck --filter=erp --filter=mes --filter=@carbon/database`+ and `pnpm run lint` pass.++## Open questions++- [x] How should job step markers be remapped on version activation? —+ **Answer:** Add a `rootStepId` provenance column mirroring `rootInstructionId`,+ persisting the map `copyAssemblyInstructionAsVersion` already computes, and+ remap exactly. Chosen over re-sync-only (wipes all operator progress on every+ activation) and `sortOrder`/title matching (silently mis-attributes completed+ work in exactly the reorder+delete case that was reproduced).+- [x] Should the fix also cover the `ON DELETE SET NULL` orphan issue? —+ **Answer:** Yes. Let re-sync re-adopt orphaned steps so users can self-heal;+ today a re-sync doubles the step list instead. The FK semantics stay unchanged.+- [x] How should already-broken jobs be repaired? — **Answer:** Best-effort+ migration matching by title then `sortOrder`, with UI re-sync as the completion+ path for anything unmatched. Exact remap is impossible retroactively because+ the mapping was never persisted.+- [x] Should activation be blocked while jobs are in flight? — **Answer:** No+ (resolved during writing, §Non-goals). Activation is the intended mechanism for+ rolling a change to the floor; blocking it would break the feature's purpose.+- [x] Should the backfill also repair `NULL` markers? — **Answer:** No (resolved+ during writing). Their lineage is unrecoverable and guessing risks+ mis-attributing operator work; §3 makes them repairable from the UI instead.++## Changelog++- 2026-09-10 — Initial spec. Root cause confirmed and reproduced end-to-end in+ the UI; three open questions resolved with the user before writing.diff --git a/apps/erp/app/modules/production/production.service.test.ts b/apps/erp/app/modules/production/production.service.test.tsindex ee977b47c5..fd33624b91 100644--- a/apps/erp/app/modules/production/production.service.test.ts+++ b/apps/erp/app/modules/production/production.service.test.ts@@ -29,6 +29,8 @@ vi.mock("@lingui/core/macro", () => ({const {planAssemblyStepMarkerSync,+ planAssemblyStepMarkerRemap,+ planOrphanStepAdoption,maxToolQuantityByItem,buildAssemblyToolStepLinks,duplicateJobOperationStep@@ -69,6 +71,154 @@ describe("planAssemblyStepMarkerSync", () => {});});+// ── Assembly version activation: marker remap across versions ────────────────+describe("planAssemblyStepMarkerRemap", () => {+ it("maps a v1 step id to the v2 step copied from it", () => {+ const remap = planAssemblyStepMarkerRemap(+ [{ id: "v1a", rootStepId: null }],+ [{ id: "v2a", rootStepId: "v1a" }]+ );+ expect(remap.get("v1a")).toBe("v2a");+ });++ it("maps across three versions via the flat root chain", () => {+ // v3 copied from v2 still roots at v1.+ const remap = planAssemblyStepMarkerRemap(+ [{ id: "v2a", rootStepId: "v1a" }],+ [{ id: "v3a", rootStepId: "v1a" }]+ );+ expect(remap.get("v2a")).toBe("v3a");+ });++ it("maps regardless of reordering", () => {+ const remap = planAssemblyStepMarkerRemap(+ [+ { id: "v1a", rootStepId: null },+ { id: "v1b", rootStepId: null }+ ],+ [+ { id: "v2b", rootStepId: "v1b" },+ { id: "v2a", rootStepId: "v1a" }+ ]+ );+ expect(remap.get("v1a")).toBe("v2a");+ expect(remap.get("v1b")).toBe("v2b");+ });++ it("leaves a deleted step unmapped", () => {+ const remap = planAssemblyStepMarkerRemap(+ [+ { id: "v1a", rootStepId: null },+ { id: "v1gone", rootStepId: null }+ ],+ [{ id: "v2a", rootStepId: "v1a" }]+ );+ expect(remap.get("v1a")).toBe("v2a");+ expect(remap.has("v1gone")).toBe(false);+ });++ it("ignores a step added in the new version", () => {+ const remap = planAssemblyStepMarkerRemap(+ [{ id: "v1a", rootStepId: null }],+ [+ { id: "v2a", rootStepId: "v1a" },+ { id: "v2new", rootStepId: null }+ ]+ );+ expect(remap.size).toBe(1);+ });++ it("collapses every old version in the group onto the new step", () => {+ // activateAssemblyInstructionVersion passes ALL sibling versions as+ // otherVersionIds, so oldSteps can span v1 AND v2 while v3 is activated.+ // Both collapse to the same target; harmless only because an operation's+ // markers all come from ONE version, so at most one entry matches a row.+ const remap = planAssemblyStepMarkerRemap(+ [+ { id: "v1a", rootStepId: null },+ { id: "v2a", rootStepId: "v1a" }+ ],+ [{ id: "v3a", rootStepId: "v1a" }]+ );+ expect(remap.get("v1a")).toBe("v3a");+ expect(remap.get("v2a")).toBe("v3a");+ });++ it("does not map a step to itself", () => {+ const remap = planAssemblyStepMarkerRemap(+ [{ id: "same", rootStepId: null }],+ [{ id: "same", rootStepId: null }]+ );+ expect(remap.size).toBe(0);+ });+});++// ── Assembly → BoP sync: reclaiming orphaned (null-marker) steps ─────────────+describe("planOrphanStepAdoption", () => {+ it("adopts an orphan matching a source step on sortOrder and name", () => {+ const adoption = planOrphanStepAdoption(+ [{ id: "src1", title: "Fit cover", sortOrder: 1 }],+ [{ id: "orphan1", name: "Fit cover", sortOrder: 1 }],+ new Set()+ );+ expect(adoption.get("orphan1")).toBe("src1");+ });++ it("ignores an orphan whose name differs", () => {+ const adoption = planOrphanStepAdoption(+ [{ id: "src1", title: "Fit cover", sortOrder: 1 }],+ [{ id: "handmade", name: "Operator note", sortOrder: 1 }],+ new Set()+ );+ expect(adoption.size).toBe(0);+ });++ it("does not claim a source step an existing marked step already owns", () => {+ const adoption = planOrphanStepAdoption(+ [{ id: "src1", title: "Fit cover", sortOrder: 1 }],+ [{ id: "orphan1", name: "Fit cover", sortOrder: 1 }],+ new Set(["src1"])+ );+ expect(adoption.size).toBe(0);+ });++ it("adopts a null-titled source step via its positional placeholder name", () => {+ // The sync writes name = title || `Step ${index + 1}`, so a null title+ // becomes "Step 1" on the job step. Comparing against the raw title would+ // never match and would insert a duplicate instead of healing.+ const adoption = planOrphanStepAdoption(+ [{ id: "src1", title: null, sortOrder: 1 }],+ [{ id: "orphan1", name: "Step 1", sortOrder: 1 }],+ new Set()+ );+ expect(adoption.get("orphan1")).toBe("src1");+ });++ it("uses the source's own index for the placeholder name", () => {+ const adoption = planOrphanStepAdoption(+ [+ { id: "src1", title: "Real title", sortOrder: 1 },+ { id: "src2", title: null, sortOrder: 2 }+ ],+ [{ id: "orphan2", name: "Step 2", sortOrder: 2 }],+ new Set()+ );+ expect(adoption.get("orphan2")).toBe("src2");+ });++ it("adopts each orphan at most once", () => {+ const adoption = planOrphanStepAdoption(+ [+ { id: "src1", title: "Same", sortOrder: 1 },+ { id: "src2", title: "Same", sortOrder: 1 }+ ],+ [{ id: "orphan1", name: "Same", sortOrder: 1 }],+ new Set()+ );+ expect(adoption.size).toBe(1);+ });+});+// ── Assembly → BoP sync: tool quantity ratchet ───────────────────────────────describe("maxToolQuantityByItem", () => {it("takes the max quantity any step asks for, defaulting null to 1", () => {diff --git a/apps/erp/app/modules/production/production.service.ts b/apps/erp/app/modules/production/production.service.tsindex 32dfa30b1f..9e3b94759e 100644--- a/apps/erp/app/modules/production/production.service.ts+++ b/apps/erp/app/modules/production/production.service.ts@@ -25,6 +25,7 @@ import { parseDate } from "@internationalized/date";import type { FileObject, StorageError } from "@supabase/storage-js";import type { PostgrestError, SupabaseClient } from "@supabase/supabase-js";import type { ExpressionBuilder } from "kysely";+import { sql } from "kysely";import { nanoid } from "nanoid";import type { z } from "zod";import type { StorageItem } from "~/types";@@ -6427,6 +6428,10 @@ export async function copyAssemblyInstructionAsVersion(parentStepId: step.parentStepId? (stepIdMap.get(step.parentStepId) ?? null): null,+ // Lineage across versions: a step copied from v1 roots at v1's step, and+ // a v3 copied from v2 still roots at v1 — the chain stays flat so+ // COALESCE("rootStepId", "id") identifies the group at any depth.+ rootStepId: step.rootStepId ?? step.id,companyId,createdBy: userId};@@ -6487,9 +6492,17 @@ export async function copyAssemblyInstructionAsVersion(*/export async function activateAssemblyInstructionVersion(client: SupabaseClient<Database>,- args: { id: string; companyId: string; userId: string }+ args: {+ id: string;+ companyId: string;+ userId: string;+ // Node Kysely handle for the per-operation re-sync. Built by the route+ // action (getDatabaseClient) and passed in — never constructed here; this+ // module is bundled for the browser (see the note above getJob).+ db: Kysely<KyselyDatabase>;+ }) {- const { id, companyId, userId } = args;+ const { id, companyId, userId, db } = args;const target = await client.from("assemblyInstruction")@@ -6566,6 +6579,79 @@ export async function activateAssemblyInstructionVersion(.update({ assemblyInstructionId: id }).in("id", staleOpIds);if (repoint.error) return repoint;++ // Migrate step markers v(old) -> v(new) by lineage group before syncing.+ // Without this the job's steps still point at the old version's step ids,+ // MES cannot match them (AssemblyView findIndex -> -1), and playback+ // silently degrades to a static model on every step.+ const [oldStepRows, newStepRows] = await Promise.all([+ client+ .from("assemblyInstructionStep")+ .select("id, rootStepId")+ .in("assemblyInstructionId", otherVersionIds)+ .eq("companyId", companyId),+ client+ .from("assemblyInstructionStep")+ .select("id, rootStepId")+ .eq("assemblyInstructionId", id)+ .eq("companyId", companyId)+ ]);+ if (oldStepRows.error) return oldStepRows;+ if (newStepRows.error) return newStepRows;++ const remap = planAssemblyStepMarkerRemap(+ oldStepRows.data ?? [],+ newStepRows.data ?? []+ );++ // One statement, one transaction: the repoint above has already committed,+ // so until every marker moves, these operations point at the new version+ // while their steps still name the old one — precisely the state MES reads+ // as "no playback". Migrating them row by row would expose that window on+ // every activation, and an error midway would leave the operation split+ // across two versions with no rollback and no way to re-run (the new+ // version is Published by then, so it is no longer a "stale" source).+ if (remap.size > 0) {+ const pairs = sql.join(+ [...remap].map(+ ([oldStepId, newStepId]) => sql`(${oldStepId}, ${newStepId})`+ )+ );+ await db.transaction().execute(async (trx) => {+ await sql`+ UPDATE "jobOperationStep" AS s+ SET "assemblyInstructionStepId" = r."newStepId"+ FROM (VALUES ${pairs}) AS r("oldStepId", "newStepId")+ WHERE s."assemblyInstructionStepId" = r."oldStepId"+ AND s."companyId" = ${companyId}+ AND s."operationId" = ANY(${staleOpIds})+ `.execute(trx);+ });+ }++ // Reconcile added/deleted steps. Marker-matched steps UPDATE in place, so+ // jobOperationStepRecord survives. Isolated per operation so one failure+ // cannot abort the activation.+ for (const operationId of staleOpIds) {+ try {+ await syncAssemblyInstructionToOperation(db, {+ assemblyInstructionId: id,+ operationId,+ companyId,+ userId+ });+ } catch (error) {+ // The remap already restored playback for surviving steps, so this+ // only leaves added/deleted steps unreconciled on one operation —+ // recoverable from the job. Logged so a systematic failure is visible.+ logger.error("Failed to re-sync assembly steps after activation", {+ assemblyInstructionId: id,+ operationId,+ companyId,+ error+ });+ }+ }}}@@ -8009,15 +8095,104 @@ function plainTextToTiptap(text: string) {* half-synced BOP would be a real bug. Guards (Draft method / unlocked job,* permissions) belong to the route — Kysely bypasses RLS.*/+/**+ * Maps a job step's marker from an OLD instruction version's step id to the+ * equivalent step id in the NEWLY-ACTIVATED version, by lineage group+ * (COALESCE(rootStepId, id) — the same idiom as rootInstructionId).+ *+ * A step that survives across versions keeps its identity even when reordered+ * or retitled, so the caller can UPDATE it in place and preserve the operator's+ * completion records. Steps with no counterpart in the new version are left+ * unmapped — the caller's re-sync then treats them as stale. Pure so the+ * remapping is unit-testable.+ *+ * `oldSteps` spans EVERY older sibling version, so several of them can share a+ * lineage root and collapse onto the same new step id. That is safe only+ * because a job operation's markers all come from a single version (both+ * writers — the step insert and planOrphanStepAdoption — only ever write ids+ * from the instruction being synced), so at most one of those entries can match+ * any given row. There is no unique constraint enforcing it.+ */+export function planAssemblyStepMarkerRemap(+ oldSteps: { id: string; rootStepId: string | null }[],+ newSteps: { id: string; rootStepId: string | null }[]+): Map<string, string> {+ const newIdByRoot = new Map<string, string>();+ for (const step of newSteps) {+ const root = step.rootStepId ?? step.id;+ // First writer wins: a well-formed version has one step per lineage group.+ if (!newIdByRoot.has(root)) newIdByRoot.set(root, step.id);+ }++ const remap = new Map<string, string>();+ for (const step of oldSteps) {+ const root = step.rootStepId ?? step.id;+ const newId = newIdByRoot.get(root);+ if (newId && newId !== step.id) remap.set(step.id, newId);+ }+ return remap;+}++/**+ * The name a synced job step is written with. `title` is nullable on the+ * instruction step but `name` is NOT NULL on the job step, so a null title+ * becomes a positional placeholder. Adoption below must compare against this+ * same value, not the raw title — otherwise a null-titled step's job step is+ * named "Step 3" and can never be matched back to its source.+ */+function assemblyStepName(title: string | null, index: number) {+ return title || `Step ${index + 1}`;+}++/**+ * Re-adopts job steps orphaned by the assemblyInstructionStepId ON DELETE SET+ * NULL cascade (deleting an instruction step nulls the marker on every live+ * job synced from it). Without this a re-sync treats them as hand-authored and+ * inserts duplicates beside them.+ *+ * Deliberately conservative: an orphan is claimed only when it matches a source+ * step on BOTH sortOrder and name AND no already-marked step claims that source+ * step. Genuinely hand-authored steps match no source step and are untouched;+ * ambiguous cases are left alone rather than guessed at.+ */+export function planOrphanStepAdoption(+ sourceSteps: { id: string; title: string | null; sortOrder: number | null }[],+ orphanSteps: { id: string; name: string | null; sortOrder: number | null }[],+ claimedSourceIds: Set<string>+): Map<string, string> {+ const adoption = new Map<string, string>();+ const takenOrphans = new Set<string>();++ sourceSteps.forEach((source, index) => {+ if (claimedSourceIds.has(source.id)) return;+ const sourceName = assemblyStepName(source.title, index);+ const match = orphanSteps.find(+ (orphan) =>+ !takenOrphans.has(orphan.id) &&+ orphan.sortOrder === source.sortOrder &&+ orphan.name === sourceName+ );+ if (match) {+ adoption.set(match.id, source.id);+ takenOrphans.add(match.id);+ }+ });+ return adoption;+}+/*** Marker-based step reconciliation for the assembly→BoP sync. Given the current* source step ids and the operation's existing synced steps (each carrying the* `assemblyInstructionStepId` provenance marker), decide which source maps onto* an existing target (update) vs. is new (insert), and which existing synced* steps are stale — their source step was removed, so they must be deleted- * (cascading their slides/links). Hand-authored steps (null marker) are excluded- * by the caller's `assemblyInstructionStepId is not null` filter; a null marker- * here is treated as stale. Pure so the reconciliation is unit-testable.+ * (cascading their slides/links).+ *+ * The caller passes only marked steps: hand-authored steps (NULL marker) are+ * filtered out, and orphans re-adopted by planOrphanStepAdoption arrive here+ * already carrying the marker they were adopted onto. A null marker reaching+ * this function is therefore treated as stale. Pure so the reconciliation is+ * unit-testable.*/export function planAssemblyStepMarkerSync(sourceStepIds: string[],@@ -8213,13 +8388,55 @@ export async function syncAssemblyInstructionToOperation(}}- const existingSynced = await trx+ const existingSteps = await trx.selectFrom(stepTable)- .select(["id", "assemblyInstructionStepId"])+ .select(["id", "assemblyInstructionStepId", "name", "sortOrder"]).where("operationId", "=", operationId).where("companyId", "=", companyId)- .where("assemblyInstructionStepId", "is not", null).execute();++ const existingSynced = existingSteps.filter(+ (step) => step.assemblyInstructionStepId !== null+ );++ // Re-adopt steps orphaned by the ON DELETE SET NULL cascade so a re-sync+ // heals them instead of inserting duplicates beside them.+ const adoption = planOrphanStepAdoption(+ sourceSteps.map((step) => ({+ id: step.id,+ title: step.title,+ sortOrder: step.sortOrder+ })),+ existingSteps+ .filter((step) => step.assemblyInstructionStepId === null)+ .map((step) => ({+ id: step.id,+ name: step.name,+ sortOrder: step.sortOrder+ })),+ new Set(+ existingSynced+ .map((step) => step.assemblyInstructionStepId)+ .filter((id): id is string => id !== null)+ )+ );++ for (const [orphanId, sourceStepId] of adoption) {+ await trx+ .updateTable(stepTable)+ .set({ assemblyInstructionStepId: sourceStepId })+ .where("id", "=", orphanId)+ .where("companyId", "=", companyId)+ .execute();+ const orphan = existingSteps.find((step) => step.id === orphanId);+ if (orphan) {+ existingSynced.push({+ ...orphan,+ assemblyInstructionStepId: sourceStepId+ });+ }+ }+const { targetIdBySourceId, staleTargetIds } = planAssemblyStepMarkerSync(sourceSteps.map((step) => step.id),existingSynced@@ -8240,7 +8457,7 @@ export async function syncAssemblyInstructionToOperation(for (const [index, source] of sourceSteps.entries()) {const payload = {- name: source.title || `Step ${index + 1}`,+ name: assemblyStepName(source.title, index),type: source.type ?? "Task",description:source.description ??diff --git a/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json b/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.jsonindex 100b9fb3cc..c70f8cd699 100644--- a/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json+++ b/apps/erp/app/routes/api+/mcp+/lib/tool-manifest.digest.json@@ -1,5 +1,5 @@{- "totalTools": 1498,+ "totalTools": 1500,"modules": 15,"tools": [{"name":"account_deleteUserAttributeValue","classification":"DESTRUCTIVE","paramCount":2,"schema":"0d38e12233b4","response":"bcde375ebd4c","injectAuth":"companyId","permission":"none"},@@ -202,7 +202,7 @@{"name":"inventory_getKanban","classification":"READ","paramCount":1,"schema":"369f807bc840","response":"c5aa7a081ed4","injectAuth":"companyId","permission":"inventory:view"},{"name":"inventory_getKanbans","classification":"READ","paramCount":2,"schema":"68cb4a73d5a9","response":"fa96e94d8dda","injectAuth":"companyId","permission":"inventory:view"},{"name":"inventory_getPickingList","classification":"READ","paramCount":1,"schema":"0a4ec3e7319b","response":"227255936b96","injectAuth":"companyId","permission":"inventory:view"},- {"name":"inventory_getPickingListAvailability","classification":"READ","paramCount":1,"schema":"0a4ec3e7319b","response":"53618db49932","injectAuth":"companyId","permission":"inventory:view"},+ {"name":"inventory_getPickingListAvailability","classification":"READ","paramCount":1,"schema":"0a4ec3e7319b","response":"9c0ac2accd52","injectAuth":"companyId","permission":"inventory:view"},{"name":"inventory_getPickingListLine","classification":"READ","paramCount":1,"schema":"063a6777d378","response":"b51ad23d436f","injectAuth":"companyId","permission":"inventory:view"},{"name":"inventory_getPickingListLines","classification":"READ","paramCount":1,"schema":"0a4ec3e7319b","response":"cc66c1b66f31","injectAuth":"companyId","permission":"inventory:view"},{"name":"inventory_getPickingListLineTrackedEntities","classification":"READ","paramCount":1,"schema":"063a6777d378","response":"51dd622ce168","injectAuth":"companyId","permission":"inventory:view"},@@ -294,7 +294,7 @@{"name":"inventory_upsertWarehouseTransfer","classification":"WRITE","paramCount":10,"schema":"8af29a9b1929","response":"3797626bd17e","injectAuth":"companyId+createdBy+updatedBy","permission":"inventory:create+update"},{"name":"inventory_upsertWarehouseTransferLine","classification":"WRITE","paramCount":1,"schema":"93538fae689b","response":"237082879d41","injectAuth":"companyId+createdBy+updatedBy","permission":"inventory:create+update"},{"name":"invoicing_applyCreditsToInvoices","classification":"DESTRUCTIVE","paramCount":4,"schema":"404db2e47d09","response":"none","injectAuth":"companyId+createdBy","permission":"invoicing:update"},- {"name":"invoicing_computeEarlyPaymentDiscounts","classification":"READ","paramCount":3,"schema":"0069677fb034","response":"53618db49932","injectAuth":"companyId","permission":"invoicing:view"},+ {"name":"invoicing_computeEarlyPaymentDiscounts","classification":"READ","paramCount":3,"schema":"0069677fb034","response":"9c0ac2accd52","injectAuth":"companyId","permission":"invoicing:view"},{"name":"invoicing_computeInvoiceDateDue","classification":"READ","paramCount":2,"schema":"c07433aded5b","response":"174e29b899b9","injectAuth":"companyId","permission":"invoicing:view"},{"name":"invoicing_createPurchaseInvoiceFromPurchaseOrder","classification":"WRITE","paramCount":1,"schema":"28cffcd9d6e8","response":"3797626bd17e","injectAuth":"companyId+createdBy+updatedBy","permission":"invoicing:create"},{"name":"invoicing_createSalesInvoiceFromSalesOrder","classification":"WRITE","paramCount":1,"schema":"d160a49d6787","response":"3797626bd17e","injectAuth":"companyId+createdBy+updatedBy","permission":"invoicing:create"},@@ -396,7 +396,7 @@{"name":"items_findChangeNoticesForItem","classification":"READ","paramCount":2,"schema":"10c8230a9f49","response":"e0196d4b0041","injectAuth":"companyId","permission":"parts:view"},{"name":"items_findOtherOpenChangeNoticesForItem","classification":"READ","paramCount":2,"schema":"8a1da983320d","response":"e0196d4b0041","injectAuth":"companyId","permission":"parts:view"},{"name":"items_getBomHasShelfLifeManagedInput","classification":"READ","paramCount":1,"schema":"623ca47a6c74","response":"7cb541e84f22","injectAuth":"companyId","permission":"parts:view"},- {"name":"items_getBomItemAttributes","classification":"READ","paramCount":1,"schema":"c4ca22fd1816","response":"53618db49932","injectAuth":"companyId","permission":"parts:view"},+ {"name":"items_getBomItemAttributes","classification":"READ","paramCount":1,"schema":"c4ca22fd1816","response":"9c0ac2accd52","injectAuth":"companyId","permission":"parts:view"},{"name":"items_getChangeNotice","classification":"READ","paramCount":1,"schema":"29578070edb2","response":"09c0b464284c","injectAuth":"companyId","permission":"parts:view"},{"name":"items_getChangeNoticeActions","classification":"READ","paramCount":1,"schema":"29578070edb2","response":"949f86b5cda3","injectAuth":"companyId","permission":"parts:view"},{"name":"items_getChangeNoticeAffectedItems","classification":"READ","paramCount":1,"schema":"29578070edb2","response":"5483e69d7515","injectAuth":"companyId","permission":"parts:view"},@@ -583,7 +583,7 @@{"name":"people_getEmployeeSummary","classification":"READ","paramCount":1,"schema":"3d90cb5d0437","response":"afd28b3efe9e","injectAuth":"companyId","permission":"people:view"},{"name":"people_getHoliday","classification":"READ","paramCount":1,"schema":"9189cc10f756","response":"8d2b62b6a13b","injectAuth":"companyId","permission":"people:view"},{"name":"people_getHolidays","classification":"READ","paramCount":3,"schema":"04eded31eebb","response":"1fedcd5adb59","injectAuth":"companyId","permission":"people:view"},- {"name":"people_getHolidayYears","classification":"READ","paramCount":0,"schema":"efddc7bd8bbc","response":"6752ec5720d7","injectAuth":"companyId","permission":"people:view"},+ {"name":"people_getHolidayYears","classification":"READ","paramCount":0,"schema":"efddc7bd8bbc","response":"7dd467066555","injectAuth":"companyId","permission":"people:view"},{"name":"people_getOpenClockEntry","classification":"READ","paramCount":1,"schema":"3d90cb5d0437","response":"48d1ac3381b4","injectAuth":"companyId","permission":"people:view"},{"name":"people_getPeople","classification":"READ","paramCount":3,"schema":"04eded31eebb","response":"5483e69d7515","injectAuth":"companyId","permission":"people:view"},{"name":"people_getRecentTimecards","classification":"READ","paramCount":0,"schema":"efddc7bd8bbc","response":"579660621675","injectAuth":"companyId","permission":"people:view"},@@ -663,7 +663,7 @@{"name":"production_getAssemblyInstructions","classification":"READ","paramCount":5,"schema":"902de08eaf06","response":"845b5a451089","injectAuth":"companyId","permission":"production:view"},{"name":"production_getAssemblyInstructionsForItem","classification":"READ","paramCount":1,"schema":"623ca47a6c74","response":"c881f4ef7d23","injectAuth":"companyId","permission":"production:view"},{"name":"production_getAssemblyInstructionStepMaterials","classification":"READ","paramCount":1,"schema":"0f56299d6859","response":"89a5f52bebf8","injectAuth":"companyId","permission":"production:view"},- {"name":"production_getAssemblyInstructionSteps","classification":"READ","paramCount":1,"schema":"f9ddf194f67e","response":"1a7606a0a35b","injectAuth":"companyId","permission":"production:view"},+ {"name":"production_getAssemblyInstructionSteps","classification":"READ","paramCount":1,"schema":"f9ddf194f67e","response":"9c00b1d03c95","injectAuth":"companyId","permission":"production:view"},{"name":"production_getAssemblyInstructionStepSlides","classification":"READ","paramCount":1,"schema":"0f56299d6859","response":"60aa9b57a118","injectAuth":"companyId","permission":"production:view"},{"name":"production_getAssemblyInstructionStepTools","classification":"READ","paramCount":1,"schema":"0f56299d6859","response":"d771814f7578","injectAuth":"companyId","permission":"production:view"},{"name":"production_getAssemblyInstructionVersions","classification":"READ","paramCount":2,"schema":"0c21424ecd86","response":"81c6e04c54bd","injectAuth":"companyId","permission":"production:view"},@@ -771,11 +771,13 @@{"name":"production_insertJob","classification":"WRITE","paramCount":2,"schema":"fea224e085b1","response":"ad63dfd9d877","injectAuth":"companyId+createdBy+updatedBy","permission":"production:create"},{"name":"production_invalidateAssemblyModelCache","classification":"DESTRUCTIVE","paramCount":1,"schema":"277f7d872d8c","response":"bcde375ebd4c","injectAuth":"companyId","permission":"production:update"},{"name":"production_issueMaterial","classification":"WRITE","paramCount":7,"schema":"0408bd8c9bde","response":"none","injectAuth":"companyId","permission":"production:update"},- {"name":"production_maxToolQuantityByItem","classification":"WRITE","paramCount":1,"schema":"8b9e90037b9a","response":"53618db49932","injectAuth":"companyId","permission":"production:update"},+ {"name":"production_maxToolQuantityByItem","classification":"WRITE","paramCount":1,"schema":"8b9e90037b9a","response":"9c0ac2accd52","injectAuth":"companyId","permission":"production:update"},{"name":"production_movePeopleAssignment","classification":"DESTRUCTIVE","paramCount":2,"schema":"a726aa587ccc","response":"fe5e1dc03da5","injectAuth":"companyId+updatedBy","permission":"production:update"},{"name":"production_movePeopleWeek","classification":"DESTRUCTIVE","paramCount":5,"schema":"fec8ebf1add4","response":"3badaa1686e8","injectAuth":"companyId+updatedBy","permission":"production:update"},{"name":"production_notifyScheduleInputsChanged","classification":"WRITE","paramCount":3,"schema":"172bee52ed70","response":"none","injectAuth":"companyId","permission":"production:update"},- {"name":"production_planAssemblyStepMarkerSync","classification":"WRITE","paramCount":2,"schema":"f32958f213ae","response":"4796bc0b8e8c","injectAuth":"companyId","permission":"production:update"},+ {"name":"production_planAssemblyStepMarkerRemap","classification":"WRITE","paramCount":2,"schema":"e8a18fd41775","response":"9c0ac2accd52","injectAuth":"companyId","permission":"production:update"},+ {"name":"production_planAssemblyStepMarkerSync","classification":"WRITE","paramCount":2,"schema":"f32958f213ae","response":"3d632ae68356","injectAuth":"companyId","permission":"production:update"},+ {"name":"production_planOrphanStepAdoption","classification":"WRITE","paramCount":3,"schema":"aae2658d9922","response":"9c0ac2accd52","injectAuth":"companyId","permission":"production:update"},{"name":"production_pullJobMaterialMakeMethod","classification":"WRITE","paramCount":2,"schema":"e27f48bbab4c","response":"bcde375ebd4c","injectAuth":"companyId","permission":"production:update"},{"name":"production_reassignAssemblyStepComponents","classification":"DESTRUCTIVE","paramCount":4,"schema":"99f3d689165d","response":"none","injectAuth":"companyId","permission":"production:update"},{"name":"production_recalculateJobMakeMethodRequirements","classification":"WRITE","paramCount":1,"schema":"3797626bd17e","response":"none","injectAuth":"companyId+updatedBy","permission":"production:update"},diff --git a/apps/erp/app/routes/x+/assembly+/$id.activate.tsx b/apps/erp/app/routes/x+/assembly+/$id.activate.tsxindex 7bfec93cf8..0c503e8335 100644--- a/apps/erp/app/routes/x+/assembly+/$id.activate.tsx+++ b/apps/erp/app/routes/x+/assembly+/$id.activate.tsx@@ -4,6 +4,7 @@ import { flash } from "@carbon/auth/session.server";import type { ActionFunctionArgs } from "react-router";import { redirect } from "react-router";import { activateAssemblyInstructionVersion } from "~/modules/production";+import { getDatabaseClient } from "~/services/database.server";import { path, requestReferrer } from "~/utils/path";export async function action({ request, params }: ActionFunctionArgs) {@@ -18,7 +19,8 @@ export async function action({ request, params }: ActionFunctionArgs) {const update = await activateAssemblyInstructionVersion(client, {id,companyId,- userId+ userId,+ db: getDatabaseClient()});if (update.error) {diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.tsindex c86fc71310..097f627c4f 100644--- a/packages/database/src/swagger-docs-schema.ts+++ b/packages/database/src/swagger-docs-schema.ts@@ -50442,6 +50442,9 @@ export default {{$ref: "#/parameters/rowFilter.assemblyInstructionStep.buildWave"},+ {+ $ref: "#/parameters/rowFilter.assemblyInstructionStep.rootStepId"+ },{$ref: "#/parameters/select"},@@ -50591,6 +50594,9 @@ export default {{$ref: "#/parameters/rowFilter.assemblyInstructionStep.buildWave"},+ {+ $ref: "#/parameters/rowFilter.assemblyInstructionStep.rootStepId"+ },{$ref: "#/parameters/preferReturn"}@@ -50694,6 +50700,9 @@ export default {{$ref: "#/parameters/rowFilter.assemblyInstructionStep.buildWave"},+ {+ $ref: "#/parameters/rowFilter.assemblyInstructionStep.rootStepId"+ },{$ref: "#/parameters/body.assemblyInstructionStep"},@@ -107065,7 +107074,7 @@ export default {properties: {id: {description:- "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",+ "Note:\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",format: "text",type: "string"},@@ -107114,7 +107123,7 @@ export default {},supplierLocationId: {description:- "Note:\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",+ "Note:\nThis is a Primary Key.<pk/>\nThis is a Foreign Key to `supplierLocation.id`.<fk table='supplierLocation' column='id'/>",format: "text",type: "string"},@@ -124870,6 +124879,12 @@ export default {buildWave: {format: "integer",type: "integer"+ },+ rootStepId: {+ description:+ "Note:\nThis is a Foreign Key to `assemblyInstructionStep.id`.<fk table='assemblyInstructionStep' column='id'/>",+ format: "text",+ type: "string"}},type: "object"@@ -170096,6 +170111,12 @@ export default {in: "query",type: "string"},+ "rowFilter.assemblyInstructionStep.rootStepId": {+ name: "rootStepId",+ required: false,+ in: "query",+ type: "string"+ },"body.receiptLine": {name: "receiptLine",description: "receiptLine",diff --git a/packages/database/src/types.ts b/packages/database/src/types.tsindex 60b748981e..dea8ca18ad 100644--- a/packages/database/src/types.ts+++ b/packages/database/src/types.ts@@ -3610,6 +3610,7 @@ export type Database = {parentStepId: string | nullplanConfidence: stringrequired: boolean | null+ rootStepId: string | nullsortOrder: numberstatus: Database["public"]["Enums"]["assemblyStepStatus"]title: string | null@@ -3642,6 +3643,7 @@ export type Database = {parentStepId?: string | nullplanConfidence?: stringrequired?: boolean | null+ rootStepId?: string | nullsortOrder?: numberstatus?: Database["public"]["Enums"]["assemblyStepStatus"]title?: string | null@@ -3674,6 +3676,7 @@ export type Database = {parentStepId?: string | nullplanConfidence?: stringrequired?: boolean | null+ rootStepId?: string | nullsortOrder?: numberstatus?: Database["public"]["Enums"]["assemblyStepStatus"]title?: string | null@@ -3768,6 +3771,13 @@ export type Database = {referencedRelation: "assemblyInstructionStep"referencedColumns: ["id"]},+ {+ foreignKeyName: "assemblyInstructionStep_rootStepId_fkey"+ columns: ["rootStepId"]+ isOneToOne: false+ referencedRelation: "assemblyInstructionStep"+ referencedColumns: ["id"]+ },{foreignKeyName: "assemblyInstructionStep_unitOfMeasureCode_fkey"columns: ["unitOfMeasureCode", "companyId"]@@ -68711,14 +68721,14 @@ export type Database = {},{foreignKeyName: "partner_id_fkey"- columns: ["supplierLocationId"]+ columns: ["id"]isOneToOne: falsereferencedRelation: "supplierLocation"referencedColumns: ["id"]},{foreignKeyName: "partner_id_fkey"- columns: ["id"]+ columns: ["supplierLocationId"]isOneToOne: falsereferencedRelation: "supplierLocation"referencedColumns: ["id"]@@ -73810,14 +73820,14 @@ export type Database = {},{foreignKeyName: "address_countryCode_fkey"- columns: ["customerCountryCode"]+ columns: ["shipmentCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]},{foreignKeyName: "address_countryCode_fkey"- columns: ["shipmentCountryCode"]+ columns: ["customerCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.tsindex 60b748981e..dea8ca18ad 100644--- a/packages/database/supabase/functions/lib/types.ts+++ b/packages/database/supabase/functions/lib/types.ts@@ -3610,6 +3610,7 @@ export type Database = {parentStepId: string | nullplanConfidence: stringrequired: boolean | null+ rootStepId: string | nullsortOrder: numberstatus: Database["public"]["Enums"]["assemblyStepStatus"]title: string | null@@ -3642,6 +3643,7 @@ export type Database = {parentStepId?: string | nullplanConfidence?: stringrequired?: boolean | null+ rootStepId?: string | nullsortOrder?: numberstatus?: Database["public"]["Enums"]["assemblyStepStatus"]title?: string | null@@ -3674,6 +3676,7 @@ export type Database = {parentStepId?: string | nullplanConfidence?: stringrequired?: boolean | null+ rootStepId?: string | nullsortOrder?: numberstatus?: Database["public"]["Enums"]["assemblyStepStatus"]title?: string | null@@ -3768,6 +3771,13 @@ export type Database = {referencedRelation: "assemblyInstructionStep"referencedColumns: ["id"]},+ {+ foreignKeyName: "assemblyInstructionStep_rootStepId_fkey"+ columns: ["rootStepId"]+ isOneToOne: false+ referencedRelation: "assemblyInstructionStep"+ referencedColumns: ["id"]+ },{foreignKeyName: "assemblyInstructionStep_unitOfMeasureCode_fkey"columns: ["unitOfMeasureCode", "companyId"]@@ -68711,14 +68721,14 @@ export type Database = {},{foreignKeyName: "partner_id_fkey"- columns: ["supplierLocationId"]+ columns: ["id"]isOneToOne: falsereferencedRelation: "supplierLocation"referencedColumns: ["id"]},{foreignKeyName: "partner_id_fkey"- columns: ["id"]+ columns: ["supplierLocationId"]isOneToOne: falsereferencedRelation: "supplierLocation"referencedColumns: ["id"]@@ -73810,14 +73820,14 @@ export type Database = {},{foreignKeyName: "address_countryCode_fkey"- columns: ["customerCountryCode"]+ columns: ["shipmentCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]},{foreignKeyName: "address_countryCode_fkey"- columns: ["shipmentCountryCode"]+ columns: ["customerCountryCode"]isOneToOne: falsereferencedRelation: "country"referencedColumns: ["alpha2"]diff --git a/packages/database/supabase/migrations/20260910093006_assembly-step-lineage.sql b/packages/database/supabase/migrations/20260910093006_assembly-step-lineage.sqlnew file mode 100644index 0000000000..ec096610fc--- /dev/null+++ b/packages/database/supabase/migrations/20260910093006_assembly-step-lineage.sql@@ -0,0 +1,90 @@+-- Assembly step lineage: links a step to the step it was copied from when a new+-- instruction version is created. Mirrors the instruction-level+-- "rootInstructionId" idiom — NULL means "I am the root", so a step's lineage+-- group is COALESCE("rootStepId", "id") (same shape as+-- 20260730153412_assembly-instructions-view.sql).+--+-- ON DELETE SET NULL: deleting an OLD version must never delete the CURRENT+-- version's steps; an orphaned step simply becomes its own root.++BEGIN;++ALTER TABLE "assemblyInstructionStep"+ ADD COLUMN IF NOT EXISTS "rootStepId" TEXT+ REFERENCES "assemblyInstructionStep"("id") ON DELETE SET NULL;++CREATE INDEX IF NOT EXISTS "assemblyInstructionStep_rootStepId_idx"+ ON "assemblyInstructionStep" ("rootStepId");++-- Backfill: repair job step markers stranded on a NON-CURRENT instruction+-- version by an activation that repointed the operation but not its steps.+-- rootStepId cannot exist retroactively, so match within the version group by+-- title first, then by sortOrder. Idempotent: the WHERE clause only selects+-- markers that disagree with their operation's instruction, so a second run+-- matches nothing.+WITH stranded AS (+ SELECT+ s."id" AS "jobStepId",+ s."companyId" AS "companyId",+ jo."assemblyInstructionId" AS "currentInstructionId",+ old."title" AS "title",+ old."sortOrder" AS "sortOrder"+ FROM "jobOperationStep" s+ JOIN "assemblyInstructionStep" old+ ON old."id" = s."assemblyInstructionStepId"+ JOIN "jobOperation" jo+ ON jo."id" = s."operationId"+ WHERE jo."assemblyInstructionId" IS NOT NULL+ AND old."assemblyInstructionId" <> jo."assemblyInstructionId"+),+-- Rank every plausible (stranded step -> new step) pairing, best match first.+-- Title equality is a strong PREFERENCE, not a join condition: renaming steps is+-- one of the main reasons to cut a new version, and gating on an exact title+-- would silently skip exactly those steps. sortOrder equality breaks the tie, so+-- a retitled step still matches by position.+--+-- Both directions are ranked because a single "best match" per job step is not+-- enough: two stranded steps sharing a title both resolved to the same new step,+-- and since planAssemblyStepMarkerSync builds its target map last-writer-wins,+-- the loser was silently dropped — never updated, never stale (its marker is+-- valid), left on the job forever as an invisible duplicate.+candidates AS (+ SELECT+ st."jobStepId",+ nw."id" AS "newStepId",+ ROW_NUMBER() OVER (+ PARTITION BY st."jobStepId"+ ORDER BY+ (nw."title" IS NOT DISTINCT FROM st."title") DESC,+ (nw."sortOrder" IS NOT DISTINCT FROM st."sortOrder") DESC,+ nw."sortOrder" ASC,+ nw."id" ASC+ ) AS "stepRank",+ ROW_NUMBER() OVER (+ PARTITION BY nw."id"+ ORDER BY+ (nw."title" IS NOT DISTINCT FROM st."title") DESC,+ (nw."sortOrder" IS NOT DISTINCT FROM st."sortOrder") DESC,+ st."sortOrder" ASC,+ st."jobStepId" ASC+ ) AS "claimRank"+ FROM stranded st+ JOIN "assemblyInstructionStep" nw+ ON nw."assemblyInstructionId" = st."currentInstructionId"+ AND nw."companyId" = st."companyId"+),+-- One new step is claimed by at most one job step, and vice versa. A pairing+-- that loses either race is left alone rather than guessed at — the operation's+-- "Sync Assembly Steps" finishes the repair.+matched AS (+ SELECT "jobStepId", "newStepId"+ FROM candidates+ WHERE "stepRank" = 1+ AND "claimRank" = 1+)+UPDATE "jobOperationStep" s+SET "assemblyInstructionStepId" = m."newStepId"+FROM matched m+WHERE s."id" = m."jobStepId";++COMMIT;diff --git a/packages/jobs/manifests/schema.json b/packages/jobs/manifests/schema.jsonindex c926c647ad..a452db122b 100644--- a/packages/jobs/manifests/schema.json+++ b/packages/jobs/manifests/schema.json@@ -1,11 +1,11 @@{"kind": "carbon-company-backup","version": 1,- "schemaVersion": "20260909174352",+ "schemaVersion": "20260910093006","sourceCompanyId": "schema-baseline","sourceCompanyGroupId": null,"sourceCompanyName": null,- "exportedAt": "2026-09-09T21:54:43.367Z",+ "exportedAt": "2026-09-10T09:58:59.067Z","exportedBy": "schema-baseline","label": "schema baseline","includeStorage": "none",@@ -120,67 +120,67 @@"name": "accountingPeriodBalance","rows": 0,"columns": [- "id",- "updatedBy",+ "endingBalance",+ "createdBy",+ "accountingPeriodId",+ "accountId","endingBalanceDate",- "companyId",+ "updatedBy",+ "id","createdAt","updatedAt",- "endingBalance",- "accountId",- "accountingPeriodId",- "createdBy"+ "companyId"]},{"name": "accountingSyncOperation","rows": 0,"columns": [- "direction",- "lastAttemptAt",- "id",- "idempotencyKey",- "attemptCount",- "status",- "companyId",- "errorCode",- "metadata",- "createdBy",- "externalId",- "updatedAt",- "completedAt",- "entityId","trigger",- "createdAt",- "updatedBy",- "entityType",+ "integration","errorMessage",- "integration"+ "entityType",+ "updatedBy",+ "createdAt",+ "externalId",+ "createdBy",+ "entityId",+ "completedAt",+ "updatedAt",+ "status",+ "attemptCount",+ "metadata",+ "errorCode",+ "companyId",+ "direction",+ "idempotencyKey",+ "id",+ "lastAttemptAt"]},{"name": "accountingSyncTieOut","rows": 0,"columns": [- "accountId",- "providerAmount","computedAt","createdAt",+ "accountId",+ "providerAmount",+ "syncedAmount","updatedAt","updatedBy",+ "accountingPeriodId","externalDelta","integration",- "accountingPeriodId",- "syncedAmount",+ "carbonPostedAmount","blockedAmount",- "excludedAmount","id",- "carbonPostedAmount",+ "excludedAmount",+ "pendingAmount",+ "docBackedAmount","internalDelta","companyId",- "createdBy",- "pendingAmount",- "docBackedAmount"+ "createdBy"]},{@@ -203,16 +203,16 @@"name": "agentThread","rows": 0,"columns": [- "modelId","title","userId","createdBy",- "id",- "updatedBy",- "lastContext",+ "modelId","companyId","updatedAt",- "createdAt"+ "createdAt",+ "id",+ "updatedBy",+ "lastContext"]},{@@ -231,32 +231,32 @@"createdAt","feedbackNote","role",- "updatedAt",- "companyId"+ "companyId",+ "updatedAt"]},{"name": "agentMessagePart","rows": 0,"columns": [- "updatedBy",- "createdBy",- "toolState",- "type",- "toolName",- "updatedAt",- "orderIndex",- "errorMessage",- "companyId",- "textContent","toolOutput","id","toolCallId",- "toolInput",- "toolClassification",+ "textContent","messageId","toolDurationMs",- "createdAt"+ "createdAt",+ "toolInput",+ "toolClassification",+ "toolState",+ "type",+ "updatedBy",+ "createdBy",+ "updatedAt",+ "orderIndex",+ "companyId",+ "errorMessage",+ "toolName"]},{@@ -271,111 +271,111 @@"companyId","amount","decisionAt",+ "updatedAt","documentType","createdBy",- "updatedAt","requestedBy",- "decisionNotes","decisionBy",- "id"+ "id",+ "decisionNotes"]},{"name": "approvalRule","rows": 0,"columns": [- "lowerBoundAmount",+ "documentType",+ "createdAt",+ "companyId","updatedBy","id","createdBy",- "createdAt",- "companyId",- "documentType",- "defaultApproverId",- "updatedAt",- "escalationDays",+ "lowerBoundAmount","approverGroupIds",- "enabled"+ "enabled",+ "escalationDays",+ "defaultApproverId",+ "updatedAt"]},{"name": "auditLogArchive","rows": 0,"columns": [- "rowCount",- "id",- "createdAt","companyId",- "endDate",- "sizeBytes",+ "createdAt",+ "id",+ "rowCount",+ "startDate","archivePath",- "startDate"+ "sizeBytes",+ "endDate"]},{"name": "changeOrderRequiredAction","rows": 0,"columns": [- "createdBy",- "updatedBy",- "name",- "active",+ "updatedAt",+ "companyId","createdAt",- "customFields","id",- "updatedAt",- "companyId"+ "customFields",+ "updatedBy",+ "active",+ "name",+ "createdBy"]},{"name": "changeOrderType","rows": 0,"columns": [- "updatedBy",- "companyId",- "createdAt","createdBy",- "name",+ "createdAt",+ "companyId",+ "updatedBy",+ "id","updatedAt",- "id"+ "name"]},{"name": "companyAccountsPayableBillingAddress","rows": 0,"columns": [- "postalCode",- "addressLine2",- "addressLine1","updatedAt","city",- "fax",- "countryCode",- "name",- "updatedBy",- "state",+ "addressLine1",+ "addressLine2",+ "postalCode","email",+ "phone","id",- "phone"+ "state",+ "name",+ "updatedBy",+ "fax",+ "countryCode"]},{"name": "companyAccountsReceivableBillingAddress","rows": 0,"columns": [+ "updatedAt",+ "city",+ "postalCode",+ "addressLine2",+ "addressLine1","state",- "phone",- "id","email",- "countryCode",+ "id",+ "phone","fax",- "updatedBy",+ "countryCode","name",- "city",- "updatedAt",- "postalCode",- "addressLine1",- "addressLine2"+ "updatedBy"]},{@@ -436,14 +436,14 @@"name": "companyUsage","rows": 0,"columns": [- "createdAt",- "tasks",- "aiTokens",- "nextResetDatetime",- "updatedAt","users",+ "updatedAt",+ "id","companyId",- "id"+ "aiTokens",+ "tasks",+ "createdAt",+ "nextResetDatetime"]},{@@ -484,16 +484,16 @@"name": "costCenter","rows": 0,"columns": [- "updatedAt",- "ownerId",- "name",- "createdAt",- "customFields",- "id",+ "createdBy","updatedBy","parentCostCenterId","companyId",- "createdBy"+ "createdAt",+ "customFields",+ "id",+ "ownerId",+ "updatedAt",+ "name"]},{@@ -585,15 +585,15 @@"name": "depreciationRun","rows": 0,"columns": [- "id","createdBy",+ "id","postedBy","depreciationRunId","updatedBy","createdAt","postedAt",- "status","periodEnd",+ "status","companyId"]},@@ -601,30 +601,30 @@"name": "dimension","rows": 0,"columns": [- "name",- "createdAt",- "updatedAt",- "id",- "updatedBy",- "required",+ "active","companyGroupId","entityType","createdBy",- "active"+ "id",+ "updatedBy",+ "required",+ "name",+ "createdAt",+ "updatedAt"]},{"name": "dimensionValue","rows": 0,"columns": [- "createdAt","id",- "updatedAt",+ "createdAt","dimensionId",+ "updatedAt","createdBy",- "updatedBy","name",- "companyGroupId"+ "companyGroupId",+ "updatedBy"]},{@@ -653,20 +653,20 @@"name": "documentExtraction","rows": 0,"columns": [- "sourceDocument",- "updatedAt",- "sourceDocumentId",- "status",- "storagePath","createdAt",- "updatedBy",- "companyId",- "error",- "extractedData",+ "storagePath",+ "status",+ "sourceDocumentId",+ "updatedAt",+ "sourceDocument",+ "documentType","createdBy",- "filteredData","id",- "documentType"+ "filteredData",+ "error",+ "extractedData",+ "companyId",+ "updatedBy"]},{@@ -683,35 +683,35 @@"name": "documentSection","rows": 0,"columns": [- "createdBy",- "name",- "placement","content",- "updatedAt",- "createdAt",- "companyId",- "config",+ "placement",+ "name",+ "createdBy",+ "id","updatedBy",- "id"+ "config",+ "companyId",+ "updatedAt",+ "createdAt"]},{"name": "documentTemplate","rows": 0,"columns": [- "blocks",- "updatedBy",- "formatVersion",- "documentType",- "settings",+ "createdBy",+ "headerSectionId",+ "companyId",+ "updatedAt",+ "theme",+ "createdAt","id","footerSectionId",- "createdAt",- "theme",- "updatedAt",- "companyId",- "headerSectionId",- "createdBy"+ "settings",+ "formatVersion",+ "documentType",+ "updatedBy",+ "blocks"]},{@@ -769,8 +769,8 @@"config","active","operations",- "companyId","table",+ "companyId","handlerType"]},@@ -778,34 +778,34 @@"name": "exchangeRateOverride","rows": 0,"columns": [- "createdBy","rate","currencyCode","updatedBy",- "id",- "createdAt",+ "createdBy","companyId",- "updatedAt"+ "updatedAt",+ "id",+ "createdAt"]},{"name": "externalIntegrationMapping","rows": 0,"columns": [- "externalId",- "createdBy",- "metadata",- "updatedBy","entityId",+ "updatedBy","integration",- "allowDuplicateExternalId",+ "metadata",+ "createdBy",+ "externalId",+ "entityType",+ "companyId",+ "lastSyncedAt",+ "createdAt","remoteUpdatedAt","id","updatedAt",- "lastSyncedAt",- "createdAt",- "companyId",- "entityType"+ "allowDuplicateExternalId"]},{@@ -817,13 +817,17 @@"name": "fixedAssetClass","rows": 0,"columns": [- "lossOnDisposalAccountId",- "createdAt",- "usefulLifeMonths",- "updatedAt",- "macrsConvention",- "taxResidualValuePercent",- "createdBy",+ "name",+ "taxDepreciationMethod",+ "macrsPropertyClass",+ "writeOffAccountId",+ "customFields",+ "accumulatedDepreciationAccountId",+ "writeDownAccountId",+ "depreciationExpenseAccountId",+ "id",+ "gainOnDisposalAccountId",+ "residualValuePercent","bonusDepreciationPercent","companyId","description",@@ -831,31 +835,27 @@"depreciationMethod","assetAccountId","updatedBy",- "writeDownAccountId",- "depreciationExpenseAccountId",- "id",- "gainOnDisposalAccountId",- "residualValuePercent",- "name",- "taxDepreciationMethod",- "macrsPropertyClass",- "writeOffAccountId",- "customFields",- "accumulatedDepreciationAccountId"+ "lossOnDisposalAccountId",+ "createdAt",+ "usefulLifeMonths",+ "updatedAt",+ "macrsConvention",+ "createdBy",+ "taxResidualValuePercent"]},{"name": "gaugeType","rows": 0,"columns": [- "updatedAt",+ "id",+ "createdBy",+ "name",+ "updatedBy",+ "createdAt","customFields","companyId",- "createdAt",- "updatedBy",- "name",- "createdBy",- "id"+ "updatedAt"]},{@@ -895,44 +895,44 @@"name": "implementationCheckState","rows": 0,"columns": [- "createdAt",- "itemKey",- "kind",- "value",- "updatedBy",- "companyId","createdBy",+ "id","updatedAt",- "id"+ "updatedBy",+ "companyId",+ "value",+ "createdAt",+ "kind",+ "itemKey"]},{"name": "implementationFieldValue","rows": 0,"columns": [- "updatedBy",- "fieldKey",- "value","createdBy",- "updatedAt",- "companyId",+ "value",+ "fieldKey",+ "updatedBy",+ "id","createdAt",- "id"+ "companyId",+ "updatedAt"]},{"name": "implementationRow","rows": 0,"columns": [- "updatedBy",- "companyId","createdBy","updatedAt","id",+ "updatedBy",+ "companyId",+ "sortOrder","createdAt","collection",- "payload",- "sortOrder"+ "payload"]},{@@ -959,22 +959,22 @@"rows": 0,"columns": ["fullLegalName",- "userId",- "createdBy","type",- "createdAt",+ "createdBy",+ "userId","updatedAt",- "docVersion",+ "createdAt","userAgent",- "certifiedAt",+ "docVersion","title",- "expiresAt",- "companyId",+ "certifiedAt","updatedBy",+ "companyId",+ "expiresAt","docHash",- "ipAddress",+ "complianceContact","id",- "complianceContact"+ "ipAddress"]},{@@ -1054,40 +1054,40 @@"name": "intercompanyTransaction","rows": 0,"columns": [+ "updatedAt","status","sourceJournalLineId",- "updatedAt",- "createdAt",+ "amount","sourceCompanyId",+ "createdAt","targetCompanyId",- "amount",- "documentId",+ "targetJournalLineId","description","id",- "targetJournalLineId",- "companyGroupId",- "eliminationJournalId",+ "documentId",+ "currencyCode","documentType",- "currencyCode"+ "companyGroupId",+ "eliminationJournalId"]},{"name": "intercompanyEliminationLine","rows": 0,"columns": [- "role",- "intercompanyTransactionId",- "amount",- "updatedBy",- "journalLineId",- "companyId",+ "quantity",+ "id",+ "createdAt",+ "accountId","updatedAt",- "createdBy",+ "companyId","itemId",- "createdAt",- "id",- "quantity",- "accountId"+ "createdBy",+ "journalLineId",+ "updatedBy",+ "intercompanyTransactionId",+ "role",+ "amount"]},{@@ -1132,70 +1132,70 @@"name": "fixedAsset","rows": 0,"columns": [- "bonusDepreciationPercent",- "taxResidualValuePercent",- "fixedAssetId",- "updatedAt","depreciationMethod",+ "updatedAt","createdBy",- "disposalDate","customFields","residualValuePercent",+ "disposalDate",+ "bonusDepreciationPercent",+ "fixedAssetId",+ "taxResidualValuePercent",+ "serialNumber",+ "disposalMethod","id","usefulLifeMonths","companyId","taxDepreciationMethod",- "serialNumber",- "disposalMethod",- "name",- "macrsPropertyClass",- "fixedAssetClassId",- "depreciationStartDate",- "acquisitionDate",+ "createdAt","locationId","status",- "createdAt","notes",+ "name",+ "fixedAssetClassId",+ "macrsPropertyClass",+ "acquisitionDate",+ "depreciationStartDate",+ "saleProceeds",+ "acquisitionCost",+ "macrsConvention",+ "accumulatedTaxDepreciation","assetLifetimeUsage",- "description","accumulatedDepreciation","updatedBy","taxUsefulLifeMonths",- "macrsConvention",- "accumulatedTaxDepreciation",- "saleProceeds",- "acquisitionCost"+ "description"]},{"name": "depreciationRunLine","rows": 0,"columns": [- "depreciationRunId",- "journalId",- "id","companyId","fixedAssetId","amount",- "taxAmount"+ "taxAmount",+ "depreciationRunId",+ "journalId",+ "id"]},{"name": "fixedAssetDisposal","rows": 0,"columns": [- "fixedAssetId",- "journalId",- "createdAt",+ "netBookValueAtDisposal","companyId","id","createdBy",- "netBookValueAtDisposal",- "disposalMethod",- "disposalDate",- "gainLoss",+ "journalId",+ "createdAt",+ "fixedAssetId","saleProceeds",- "updatedBy"+ "updatedBy",+ "gainLoss",+ "disposalMethod",+ "disposalDate"]},{@@ -1217,36 +1217,36 @@"name": "inventoryCount","rows": 0,"columns": [- "customFields",- "createdAt",- "companyId",- "snapshotAt",- "postedBy",+ "isBlind",+ "postedAt","id","notes",- "postedAt",- "isBlind",+ "postedBy",+ "snapshotAt",+ "createdAt",+ "companyId",+ "customFields",+ "updatedAt",+ "status",+ "createdBy",+ "scope","locationId",- "updatedBy","inventoryCountId",- "scope",- "status",- "createdBy",- "updatedAt"+ "updatedBy"]},{"name": "maintenanceFailureMode","rows": 0,"columns": [- "name",- "type","id","updatedBy",- "companyId",+ "name",+ "type",+ "createdAt","createdBy",- "updatedAt",- "createdAt"+ "companyId",+ "updatedAt"]},{@@ -1268,7 +1268,7 @@{"name": "materialDimension","rows": 0,- "columns": ["companyId", "isMetric", "name", "id", "materialFormId"]+ "columns": ["name", "isMetric", "companyId", "materialFormId", "id"]},{"name": "materialSubstance",@@ -1294,18 +1294,18 @@{"name": "materialGrade","rows": 0,- "columns": ["name", "companyId", "id", "materialSubstanceId"]+ "columns": ["companyId", "name", "id", "materialSubstanceId"]},{"name": "materialType","rows": 0,"columns": [- "companyId",- "id",- "name",- "materialFormId",+ "code","materialSubstanceId",- "code"+ "materialFormId",+ "name",+ "id",+ "companyId"]},{@@ -1370,16 +1370,16 @@"rows": 0,"columns": ["planPath",- "kind",- "status","error",- "createdBy",+ "status",+ "kind",+ "stats","id",+ "createdBy","updatedAt",- "stats",- "modelUploadId","companyId",- "createdAt"+ "createdAt",+ "modelUploadId"]},{@@ -1387,94 +1387,94 @@"rows": 0,"columns": ["createdBy",+ "updatedAt","createdAt","companyId",- "updatedAt",- "id","updatedBy",- "name",- "customFields"+ "id",+ "customFields",+ "name"]},{"name": "nonConformanceRequiredAction","rows": 0,"columns": [- "createdBy",- "systemType",- "id",- "updatedBy",- "companyId","createdAt",- "updatedAt",+ "active","name",- "active"+ "updatedAt",+ "id",+ "systemType",+ "createdBy",+ "companyId",+ "updatedBy"]},{"name": "nonConformanceType","rows": 0,"columns": [- "id",- "updatedAt","name","customFields",- "createdBy",+ "id",+ "updatedAt","createdAt","companyId",- "updatedBy"+ "updatedBy",+ "createdBy"]},{"name": "nonConformanceWorkflow","rows": 0,"columns": [+ "createdBy",+ "description",+ "content",+ "requiredActionIds","priority","companyId","updatedAt",- "content",- "description",- "createdBy",- "requiredActionIds",- "id",- "approvalRequirements",- "tags",- "source","updatedBy","createdAt","name",- "active"+ "active",+ "approvalRequirements",+ "id",+ "tags",+ "source"]},{"name": "nonConformance","rows": 0,"columns": [- "assignee",- "content",- "source",- "tags",- "updatedAt",- "closeDate",- "customFields",- "openDate",- "quantity",- "description",- "nonConformanceTypeId",- "name",- "companyId",- "priority",+ "locationId",+ "nonConformanceId",+ "dueDate",+ "createdAt",+ "approvalRequirements",+ "requiredActionIds","updatedBy","nonConformanceWorkflowId","id","createdBy","status",- "nonConformanceId",- "locationId",- "dueDate",- "approvalRequirements",- "createdAt",- "requiredActionIds"+ "quantity",+ "description",+ "name",+ "nonConformanceTypeId",+ "companyId",+ "priority",+ "source",+ "assignee",+ "content",+ "tags",+ "openDate",+ "customFields",+ "updatedAt",+ "closeDate"]},{@@ -1482,90 +1482,90 @@"rows": 0,"columns": ["type",- "openDate","changeOrderTypeId","id",- "updatedBy",- "nonConformanceId",+ "openDate","priority",- "requiredActionIds",- "changeOrderId",+ "nonConformanceId",+ "updatedBy","sourceId",- "createdAt",- "sourceType",+ "changeOrderId",+ "requiredActionIds","assignee",- "description",+ "sourceType",+ "createdAt",+ "createdBy","dueDate","companyId",- "createdBy",+ "description","status","updatedAt",- "tags",- "customFields","approvalRequirements","name",- "reasonForChange"+ "reasonForChange",+ "customFields",+ "tags"]},{"name": "changeOrderActionTask","rows": 0,"columns": [- "status",- "updatedAt",- "name",- "assignee","createdAt","dueDate","updatedBy",- "actionTypeId",+ "updatedAt",+ "name",+ "status",+ "assignee",+ "companyId",+ "sortOrder",+ "id",+ "completedDate","changeOrderId","createdBy",- "notes",+ "actionTypeId","tags",- "id",- "sortOrder",- "companyId",- "completedDate"+ "notes"]},{"name": "nonConformanceApprovalTask","rows": 0,"columns": [- "createdBy",- "nonConformanceId",- "notes",- "tags",+ "updatedBy",+ "dueDate",+ "createdAt",+ "assignee",+ "status",+ "updatedAt",+ "approvalType",+ "completedDate","id","sortOrder","companyId",- "completedDate",- "status",- "approvalType",- "updatedAt",- "assignee",- "dueDate",- "createdAt",- "updatedBy"+ "notes",+ "tags",+ "createdBy",+ "nonConformanceId"]},{"name": "nonConformanceReviewer","rows": 0,"columns": [- "notes",- "completedDate","status","nonConformanceId","companyId",+ "completedDate",+ "notes",+ "title",+ "createdAt",+ "updatedAt","createdBy","id","updatedBy",- "assignee",- "title",- "createdAt",- "updatedAt"+ "assignee"]},{@@ -1588,49 +1588,49 @@"name": "notification","rows": 0,"columns": [- "title",- "id",- "documentType",- "payload",+ "description",+ "digestedInto",+ "companyId",+ "topic",+ "createdAt",+ "readAt",+ "event","from","documentId","userId","seenAt",- "createdAt",- "readAt",- "event",- "description",- "topic",- "companyId",- "digestedInto"+ "title",+ "documentType",+ "id",+ "payload"]},{"name": "notificationDelivery","rows": 0,"columns": [- "companyId",+ "lastDeliveryId",+ "userId",+ "event",+ "documentId","lastDeliveredAt",- "id",- "createdAt",+ "companyId","successCount",- "event",- "userId",- "lastDeliveryId",- "documentId"+ "createdAt",+ "id"]},{"name": "notificationPreference","rows": 0,"columns": [- "userId",- "id","enabled",- "companyId",- "channel",+ "id",+ "userId",+ "topic","updatedAt",- "topic"+ "companyId",+ "channel"]},{@@ -1692,49 +1692,49 @@"name": "periodCloseTaskDefinition","rows": 0,"columns": [- "updatedAt",- "createdBy",- "autoCheckKey",- "required","taskType",- "name","updatedBy",- "sortOrder",+ "name",+ "required",+ "autoCheckKey",+ "createdBy",+ "updatedAt",+ "customFields",+ "createdAt",+ "companyId",+ "severity",+ "isSystem","id","active","defaultAssigneeId",- "severity",- "isSystem",- "customFields",- "companyId",- "createdAt"+ "sortOrder"]},{"name": "periodCloseTask","rows": 0,"columns": [- "taskType",+ "status","required","id",- "status",- "sortOrder",- "severity",- "evidenceJournalId",- "companyId",+ "taskType","completedBy",- "notes",- "skippedReason",- "updatedAt",+ "companyId",+ "evidenceJournalId",+ "severity",+ "sortOrder",+ "name","assigneeId","updatedBy",- "name",- "autoCheckKey",+ "updatedAt",+ "skippedReason",+ "notes",+ "createdAt",+ "createdBy","completedAt","accountingPeriodId","definitionId",- "createdBy",- "createdAt"+ "autoCheckKey"]},{@@ -1742,85 +1742,85 @@"rows": 0,"columns": ["notes",- "status","locationId",- "updatedAt",+ "status","assignee",- "createdAt",+ "updatedAt","companyId",- "pickingListId",+ "createdAt","customFields",+ "pickingListId","dueDate",- "updatedBy",+ "id","createdBy",- "id"+ "updatedBy"]},{"name": "pricingRule","rows": 0,"columns": [- "validFrom",- "name",- "maxQuantity",- "customerTypeIds",- "customerIds",- "id",- "itemIds",- "priority",- "validTo",- "ruleType",- "amountType",- "createdBy",- "companyId",- "minQuantity",- "updatedAt",- "amount","itemPostingGroupId","createdAt",+ "amount",+ "updatedAt",+ "active","updatedBy",- "active"+ "companyId",+ "createdBy",+ "ruleType",+ "validTo",+ "amountType",+ "minQuantity",+ "itemIds",+ "customerIds",+ "id",+ "priority",+ "name",+ "validFrom",+ "customerTypeIds",+ "maxQuantity"]},{"name": "printJob","rows": 0,"columns": [- "error",- "content",- "updatedBy",- "createdAt",- "contentType",- "createdBy",- "status",- "completedAt",- "sourceDocument",- "id",- "sourceDocumentReadableId",- "origin",- "printerUrl",+ "sourceDocumentId",+ "description","updatedAt","companyId","attempts",- "sourceDocumentId",- "description"+ "printerUrl",+ "id",+ "sourceDocumentReadableId",+ "origin",+ "sourceDocument",+ "contentType",+ "status",+ "createdBy",+ "completedAt",+ "updatedBy",+ "createdAt",+ "error",+ "content"]},{"name": "printerRoute","rows": 0,"columns": [- "printerUrl",- "name",- "locationId",- "format","updatedAt","apiKey","companyId","mediaSizeId","templateId",+ "createdAt","id",- "createdAt"+ "printerUrl",+ "locationId",+ "name",+ "format"]},{@@ -1880,58 +1880,58 @@"name": "procedure","rows": 0,"columns": [- "processId",- "tags",- "description",- "content",- "version",- "updatedAt",- "updatedBy",+ "id",+ "companyId",+ "createdBy",+ "status","name",- "createdAt",+ "updatedBy","assignee",- "createdBy",- "companyId",- "id",- "status"+ "createdAt",+ "updatedAt",+ "version",+ "description",+ "processId",+ "tags",+ "content"]},{"name": "procedureParameter","rows": 0,"columns": [- "createdAt","id","updatedBy",- "updatedAt",+ "createdAt","procedureId",+ "updatedAt","companyId",- "createdBy","value",- "key"+ "key",+ "createdBy"]},{"name": "purchasingRfq","rows": 0,"columns": [- "createdBy",- "updatedBy",+ "notes",+ "id",+ "assignee",+ "rfqDate",+ "updatedAt",+ "customFields",+ "rfqId",+ "internalNotes",+ "locationId","employeeId","companyId",- "expirationDate",- "status",+ "createdBy",+ "updatedBy","revisionId","createdAt",- "rfqDate",- "assignee",- "id",- "notes",- "locationId",- "internalNotes",- "customFields",- "rfqId",- "updatedAt"+ "status",+ "expirationDate"]},{@@ -1943,49 +1943,49 @@"name": "qualityDocument","rows": 0,"columns": [- "assignee",- "description",- "version","updatedBy","status",- "companyId",- "createdBy",- "name",- "tags",- "content",+ "description",+ "version",+ "assignee","createdAt","id",- "updatedAt"+ "updatedAt",+ "content",+ "name",+ "tags",+ "companyId",+ "createdBy"]},{"name": "reportPin","rows": 0,"columns": [- "createdBy","updatedBy",- "companyId","pinned",- "createdAt",- "reportKey",+ "companyId",+ "createdBy","updatedAt",- "userId"+ "userId",+ "createdAt",+ "reportKey"]},{"name": "reportView","rows": 0,"columns": [- "config",- "reportKey",- "name",- "createdBy",- "updatedBy",- "id","visibility",- "companyId",+ "id",+ "updatedBy",+ "createdAt","updatedAt",- "createdAt"+ "companyId",+ "config",+ "createdBy",+ "name",+ "reportKey"]},{@@ -2096,15 +2096,15 @@"rows": 0,"columns": ["shiftId",- "createdBy",- "employeeId","date",- "note",- "updatedBy",+ "employeeId",+ "createdBy","id",- "updatedAt",+ "updatedBy",+ "note",+ "companyId","createdAt",- "companyId"+ "updatedAt"]},{@@ -2145,124 +2145,124 @@"name": "slackDocumentThread","rows": 0,"columns": [- "channelId","createdAt","documentType","documentId",- "threadTs",- "updatedAt",- "id",+ "channelId","updatedBy","createdBy",- "companyId"+ "companyId",+ "threadTs",+ "updatedAt",+ "id"]},{"name": "ssoConnection","rows": 0,"columns": [- "metadataUrl",- "providerId",- "requireSso",- "metadataXml",+ "createdAt",+ "id",+ "updatedAt",+ "active","companyId",- "updatedBy","createdBy",- "updatedAt",- "id",- "createdAt",- "active"+ "updatedBy",+ "metadataXml",+ "providerId",+ "metadataUrl",+ "requireSso"]},{"name": "ssoDomain","rows": 0,"columns": [- "verifiedAt",- "connectionId",- "domain",- "verificationToken",+ "status",+ "id",+ "createdAt",+ "updatedAt","createdBy","updatedBy","companyId",- "status",- "createdAt",- "id",- "updatedAt"+ "verificationToken",+ "verifiedAt",+ "domain",+ "connectionId"]},{"name": "stockTransfer","rows": 0,"columns": [- "updatedBy",- "createdBy",- "stockTransferId",- "customFields",- "companyId","notes",- "id","updatedAt",- "createdAt",- "status",- "locationId",- "tags",+ "id",+ "companyId",+ "customFields",+ "stockTransferId",+ "updatedBy",+ "createdBy",+ "completedAt","assignee",- "completedAt"+ "tags",+ "locationId",+ "status",+ "createdAt"]},{"name": "storageRule","rows": 0,"columns": [- "createdAt",- "id",- "active",- "severity",- "updatedAt",- "companyId",- "appliesToAll",- "createdBy",- "surfaces",- "message",- "updatedBy",- "targetType",- "filteredItemTypes",- "filteredItemMatchAll",+ "conditionAst","filteredItemGroupIds",+ "filteredItemMatchAll","description",- "name","customFields",- "conditionAst"+ "name",+ "filteredItemTypes",+ "targetType",+ "updatedBy",+ "message",+ "createdBy",+ "surfaces",+ "companyId",+ "updatedAt",+ "appliesToAll",+ "severity",+ "createdAt",+ "id",+ "active"]},{"name": "storageType","rows": 0,"columns": [- "createdAt",- "updatedAt",- "companyId","createdBy",- "updatedBy",- "id",+ "companyId",+ "updatedAt",+ "createdAt",+ "name","customFields",- "name"+ "id",+ "updatedBy"]},{"name": "suggestion","rows": 0,"columns": [- "path",- "emoji",- "userId",- "attachmentPath",+ "createdAt",+ "id",+ "tags","suggestion","companyId",- "id",- "createdAt",- "tags"+ "attachmentPath",+ "emoji",+ "path",+ "userId"]},{@@ -2285,21 +2285,21 @@"name": "tableView","rows": 0,"columns": [- "sortOrder",- "columnVisibility",- "id",- "sorts",- "columnPinning",- "filters",- "createdAt",- "name","updatedBy","type","companyId","columnOrder","table","createdBy",- "description"+ "description",+ "sortOrder",+ "sorts",+ "columnVisibility",+ "id",+ "filters",+ "columnPinning",+ "createdAt",+ "name"]},{@@ -2329,17 +2329,17 @@"name": "timeCardEntry","rows": 0,"columns": [+ "clockOut",+ "autoCloseShiftId",+ "clockIn",+ "companyId",+ "note","id","createdAt","updatedAt",- "note",- "employeeId","createdBy","updatedBy",- "clockOut",- "clockIn",- "companyId",- "autoCloseShiftId"+ "employeeId"]},{@@ -2362,54 +2362,54 @@"name": "trackedActivity","rows": 0,"columns": [- "id",- "createdBy",- "attributes",- "type",- "createdAt",- "updatedBy",- "sourceDocumentReadableId",+ "companyId","sourceDocumentId","sourceDocument",- "companyId"+ "sourceDocumentReadableId",+ "updatedBy",+ "createdAt",+ "type",+ "attributes",+ "id",+ "createdBy"]},{"name": "training","rows": 0,"columns": [- "estimatedDuration",- "type",- "companyId","name",+ "companyId","updatedAt",- "status",+ "estimatedDuration",+ "type","tags",- "content","id",- "frequency",+ "content",+ "status","grantsAbilityId",+ "version","description","createdAt",- "version",- "createdBy",- "updatedBy",+ "frequency",+ "assignee","processId",- "assignee"+ "updatedBy",+ "createdBy"]},{"name": "trainingAssignment","rows": 0,"columns": [- "id",- "createdBy",- "trainingId",- "updatedBy",- "createdAt","companyId","groupIds",- "updatedAt"+ "updatedAt",+ "createdAt",+ "trainingId",+ "updatedBy",+ "id",+ "createdBy"]},{@@ -2417,14 +2417,14 @@"rows": 0,"columns": ["trainingAssignmentId",- "updatedBy","createdBy",- "period",- "updatedAt",+ "updatedBy","id",+ "updatedAt",+ "period","completedBy",- "employeeId","companyId",+ "employeeId","createdAt","completedAt"]@@ -2433,23 +2433,23 @@"name": "trainingQuestion","rows": 0,"columns": [- "correctNumber",- "correctBoolean",- "id",- "required",- "trainingId",+ "question",+ "createdAt",+ "type",+ "options",+ "sortOrder",+ "tolerance",+ "createdBy",+ "updatedBy","companyId",+ "trainingId","updatedAt","matchingPairs","correctAnswers",- "tolerance",- "sortOrder",- "updatedBy",- "createdBy",- "question",- "createdAt",- "type",- "options"+ "correctNumber",+ "correctBoolean",+ "id",+ "required"]},{@@ -2505,110 +2505,111 @@"name": "assemblyComponentMapping","rows": 0,"columns": [- "confidence",- "geometryHash",- "itemId",- "createdBy","updatedBy","id","companyId","modelUploadId","updatedAt",- "createdAt"+ "createdAt",+ "confidence",+ "geometryHash",+ "itemId",+ "createdBy"]},{"name": "assemblyInstruction","rows": 0,"columns": [+ "status",+ "customFields",+ "settings",+ "id",+ "companyId",+ "publishedAt","name","createdBy","updatedAt",- "companyId",- "publishedAt",- "customFields",- "id",- "settings",- "status",- "itemId",- "modelUploadId",- "createdAt",- "version",+ "rootInstructionId",+ "updatedBy","tags","assemblyPlanJobId",- "rootInstructionId",- "updatedBy"+ "version",+ "modelUploadId",+ "createdAt",+ "itemId"]},{"name": "assemblyInstructionStep","rows": 0,"columns": [- "camera",- "explode","sortOrder","parentStepId","fileTypes",+ "camera",+ "explode","updatedAt","durationSeconds","description",+ "planConfidence","fastener",+ "rootStepId","maxValue","title",- "planConfidence","createdAt","motion",- "warnings","notes",+ "warnings",+ "componentNodeIds","assemblyInstructionId","listValues",- "componentNodeIds",- "unitOfMeasureCode",- "companyId","instructionText","buildWave","status",- "updatedBy",- "minValue",+ "unitOfMeasureCode",+ "companyId","id","required",- "createdBy",- "type"+ "updatedBy",+ "minValue",+ "type",+ "createdBy"]},{"name": "assemblyInstructionStepMaterial","rows": 0,"columns": [- "createdBy",- "itemId",- "quantity",- "sortOrder",- "updatedAt",- "createdAt",- "stepId",- "companyId",+ "id","updatedBy",- "id"- ]- },- {- "name": "assemblyInstructionStepSlide",- "rows": 0,- "columns": [- "size",- "modelUploadId",- "imagePath",- "caption",- "updatedBy",- "annotations",- "createdBy",- "updatedAt",+ "companyId","stepId",+ "createdAt",+ "updatedAt","sortOrder",+ "quantity",+ "itemId",+ "createdBy"+ ]+ },+ {+ "name": "assemblyInstructionStepSlide",+ "rows": 0,+ "columns": [+ "stepId",+ "updatedAt",+ "createdBy",+ "annotations",+ "createdAt","id","companyId",- "createdAt"+ "sortOrder",+ "modelUploadId",+ "imagePath",+ "size",+ "updatedBy",+ "caption"]},{@@ -2616,13 +2617,13 @@"rows": 0,"columns": ["stepId",- "updatedAt","createdAt",- "updatedBy",+ "updatedAt","id",+ "updatedBy","companyId",- "itemId","quantity",+ "itemId","createdBy","sortOrder"]@@ -2631,52 +2632,52 @@"name": "assemblyUnit","rows": 0,"columns": [+ "companyId","id","updatedBy","sourceGroupId",- "companyId",- "modelUploadId","createdAt","updatedAt",+ "modelUploadId","itemId",+ "createdBy","componentNodeIds",- "name",- "createdBy"+ "name"]},{"name": "batchProperty","rows": 0,"columns": [+ "label",+ "dataType",+ "companyId",+ "listOptions",+ "itemId","createdAt","updatedAt",- "itemId",- "sortOrder","createdBy","id","updatedBy",- "companyId",- "label",- "dataType",- "listOptions"+ "sortOrder"]},{"name": "changeOrderSupersession","rows": 0,"columns": [- "updatedBy",- "supersessionMode",- "successorEffectivityDate",- "successorItemId",- "predecessorItemId",- "discontinuationDate",+ "changeOrderId",+ "companyId",+ "createdBy","id","createdAt","updatedAt",- "companyId",- "createdBy",- "changeOrderId"+ "discontinuationDate",+ "successorItemId",+ "predecessorItemId",+ "successorEffectivityDate",+ "updatedBy",+ "supersessionMode"]},{@@ -2686,8 +2687,8 @@"itemId","id","companyId",- "name","sortOrder",+ "name","isUngrouped"]},@@ -2695,20 +2696,20 @@"name": "configurationParameter","rows": 0,"columns": [- "label",- "materialFormFilterId",- "key",- "configurationParameterGroupId",- "updatedAt",- "dataType",- "itemId","updatedBy",+ "itemId","sortOrder","createdAt",- "companyId","id",+ "companyId","createdBy",- "listOptions"+ "listOptions",+ "key",+ "label",+ "materialFormFilterId",+ "configurationParameterGroupId",+ "dataType",+ "updatedAt"]},{@@ -2727,136 +2728,136 @@"name": "demandForecast","rows": 0,"columns": [- "companyId",- "createdAt",- "locationId",- "confidence",+ "updatedBy",+ "forecastMethod",+ "periodId",+ "forecastQuantity",+ "notes","createdBy","itemId","updatedAt",- "notes",- "periodId",- "forecastQuantity",- "updatedBy",- "forecastMethod"+ "confidence",+ "locationId",+ "companyId",+ "createdAt"]},{"name": "demandProjection","rows": 0,"columns": [- "forecastMethod",- "updatedBy",- "notes",- "periodId",- "forecastQuantity","confidence",- "createdBy","itemId",+ "createdBy","updatedAt","companyId","createdAt","id",- "locationId"+ "locationId",+ "forecastMethod",+ "updatedBy",+ "notes",+ "forecastQuantity",+ "periodId"]},{"name": "inspectionDocument","rows": 0,"columns": [- "version",- "samplingInspectionLevel",- "createdBy",- "updatedAt",- "samplingSeverity",- "samplingSampleSize","drawingNumber",- "partId","updatedBy",- "samplingAql",+ "partId","samplingPercentage",+ "samplingAql","fileName",- "id",- "defaultPageWidth",- "uploadedBy",- "storagePath",+ "samplingInspectionLevel",+ "createdBy",+ "version",+ "samplingSampleSize",+ "updatedAt",+ "samplingSeverity","samplingPlanType",- "createdAt","companyId",+ "createdAt","pageCount",- "defaultPageHeight"+ "defaultPageHeight",+ "id",+ "defaultPageWidth",+ "uploadedBy",+ "storagePath"]},{"name": "inspectionFeature","rows": 0,"columns": [- "nominalValue",- "samplingAql",- "samplingPercentage",- "companyId",- "updatedAt",- "pageNumber",+ "description",+ "toleranceMinus",+ "id",+ "createdBy",+ "tolerancePlus",+ "unit",+ "samplingPlanType",+ "updatedBy",+ "inspectionDocumentId","type","samplingSeverity","samplingSampleSize","label","createdAt","samplingInspectionLevel",- "unit",- "tolerancePlus",- "updatedBy",- "inspectionDocumentId",- "samplingPlanType",- "description",- "createdBy",- "toleranceMinus",- "id"+ "nominalValue",+ "updatedAt",+ "companyId",+ "pageNumber",+ "samplingAql",+ "samplingPercentage"]},{"name": "balloon","rows": 0,"columns": [+ "regionY","companyId","updatedBy","inspectionFeatureId",- "regionY",- "pageNumber",- "createdBy","updatedAt",- "createdAt",- "inspectionDocumentId",+ "createdBy",+ "pageNumber","regionWidth","xCoordinate",+ "inspectionDocumentId",+ "createdAt",+ "regionX","regionHeight","id",- "yCoordinate",- "regionX"+ "yCoordinate"]},{"name": "inventoryCountLine","rows": 0,"columns": [- "inventoryCountId",- "postedItemLedgerId",- "itemId",- "customFields",- "updatedAt",- "trackedEntityId",- "locationId",- "countedBy",- "createdBy",- "updatedBy",- "createdAt",- "countedAt",- "companyId",- "readableId",- "countedQuantity",+ "storageUnitId","systemQuantity","id",- "storageUnitId"+ "countedQuantity",+ "readableId",+ "countedAt",+ "companyId",+ "createdAt",+ "createdBy",+ "updatedBy",+ "locationId",+ "countedBy",+ "trackedEntityId",+ "customFields",+ "updatedAt",+ "inventoryCountId",+ "postedItemLedgerId",+ "itemId"]},{@@ -2882,14 +2883,14 @@"name": "itemInspectionDocumentAssignment","rows": 0,"columns": [+ "createdBy",+ "updatedBy","inspectionDocumentId","companyId",- "updatedBy",- "createdBy",- "usage",- "updatedAt",+ "createdAt","itemId",- "createdAt"+ "updatedAt",+ "usage"]},{@@ -2923,53 +2924,53 @@"name": "itemSerialSequence","rows": 0,"columns": [- "next",- "updatedBy",- "id",- "createdBy",- "createdAt",- "step",- "companyId","updatedAt","suffix",- "size",+ "itemId","prefix",- "itemId"+ "size",+ "createdBy",+ "id",+ "updatedBy",+ "next",+ "companyId",+ "step",+ "createdAt"]},{"name": "itemShelfLife","rows": 0,"columns": [- "updatedBy",- "itemId",- "customFields",- "companyId",- "mode",- "createdAt",- "updatedAt",- "triggerTiming",- "calculateFromBom",- "days",+ "createdBy","triggerProcessId",- "createdBy"+ "days",+ "calculateFromBom",+ "triggerTiming",+ "updatedAt",+ "createdAt",+ "mode",+ "companyId",+ "customFields",+ "itemId",+ "updatedBy"]},{"name": "itemSupersession","rows": 0,"columns": [- "updatedAt",- "itemId",- "createdAt",- "successorEffectivityDate","companyId","updatedBy","createdBy",- "discontinuationDate",- "successorItemId",+ "updatedAt",+ "createdAt",+ "itemId",+ "successorEffectivityDate","supersessionMode",- "conversionFactor"+ "successorItemId",+ "conversionFactor",+ "discontinuationDate"]},{@@ -3014,179 +3015,179 @@"name": "changeOrderAffectedItem","rows": 0,"columns": [- "draftMakeMethodId",- "newItemId",- "id",- "discontinuationDate",- "successorEffectivityDate",- "supersessionMode",- "companyId",- "changeOrderId","updatedAt",- "createdBy",- "updatedBy",- "changeType",- "changeSummary",- "baseMakeMethodId",- "sortOrder",+ "changeOrderId",+ "companyId",+ "supersessionMode",+ "successorEffectivityDate",+ "discontinuationDate",+ "id",+ "newItemId",+ "draftMakeMethodId","itemId",- "createdAt"+ "createdAt",+ "sortOrder",+ "baseMakeMethodId",+ "changeSummary",+ "changeType",+ "updatedBy",+ "createdBy"]},{"name": "nonConformanceItem","rows": 0,"columns": [+ "createdAt",+ "companyId",+ "itemId",+ "updatedAt","id","disposition","createdBy","nonConformanceId",- "updatedBy","quantity",- "createdAt",- "companyId",- "itemId",- "updatedAt"+ "updatedBy"]},{"name": "procedureStep","rows": 0,"columns": [- "maxValue",- "unitOfMeasureCode",- "companyId",- "procedureId",- "updatedAt",- "sortOrder",- "listValues",+ "fileTypes",+ "required",+ "updatedBy",+ "createdBy",+ "createdAt",+ "name",+ "description",+ "type","minValue","id",- "type",- "description",- "name",- "createdAt",- "createdBy",- "updatedBy",- "required",- "fileTypes"+ "listValues",+ "sortOrder",+ "updatedAt",+ "procedureId",+ "companyId",+ "unitOfMeasureCode",+ "maxValue"]},{"name": "purchasingRfqLine","rows": 0,"columns": [- "createdBy",- "updatedBy",- "quantity",- "companyId",- "inventoryUnitOfMeasureCode",- "description",- "createdAt",- "itemId",- "purchaseUnitOfMeasureCode",+ "updatedAt",+ "purchasingRfqId",+ "customFields",+ "conversionFactor",+ "internalNotes","id","order","externalNotes",- "conversionFactor",- "internalNotes",- "updatedAt",- "customFields",- "purchasingRfqId"+ "purchaseUnitOfMeasureCode",+ "description",+ "createdAt",+ "itemId",+ "inventoryUnitOfMeasureCode",+ "companyId",+ "quantity",+ "updatedBy",+ "createdBy"]},{"name": "qualityDocumentStep","rows": 0,"columns": [- "description",- "name",- "createdAt",- "type","fileTypes","required","updatedBy","createdBy",- "updatedAt",+ "description",+ "createdAt",+ "name",+ "type",+ "listValues",+ "id",+ "minValue",+ "sortOrder","qualityDocumentId","companyId",- "unitOfMeasureCode",+ "updatedAt","maxValue",- "id",- "minValue",- "listValues",- "sortOrder"+ "unitOfMeasureCode"]},{"name": "riskRegister","rows": 0,"columns": [+ "description",+ "updatedAt",+ "title",+ "severity","createdBy","source","updatedBy","notes",- "updatedAt",- "title",- "description",- "severity",- "assignee",- "itemId",- "id",- "sourceId","companyId","createdAt","type","status",- "likelihood"+ "likelihood",+ "assignee",+ "id",+ "itemId",+ "sourceId"]},{"name": "storageRuleItemAssignment","rows": 0,"columns": [- "createdAt",- "companyId","createdBy",- "itemId",+ "companyId",+ "createdAt",+ "ruleId","updatedBy",- "ruleId"+ "itemId"]},{"name": "trackedEntity","rows": 0,"columns": [- "attributes",- "updatedBy","status",+ "updatedBy","sourceDocument",+ "attributes","itemId","sourceDocumentId",- "createdBy",- "companyId","quantity","expirationDate",- "sourceDocumentReadableId",+ "createdBy",+ "companyId","readableId","createdAt",- "id"+ "id",+ "sourceDocumentReadableId"]},{"name": "nonConformanceItemTrackedEntity","rows": 0,"columns": [- "quantity",- "createdAt",- "nonConformanceId",- "trackedEntityId",- "companyId",- "updatedAt",- "id","createdBy","updatedBy",- "nonConformanceItemId"+ "nonConformanceItemId",+ "companyId",+ "id",+ "updatedAt",+ "createdAt",+ "trackedEntityId",+ "nonConformanceId",+ "quantity"]},{@@ -3198,8 +3199,8 @@"createdBy","id","updatedAt",- "companyId","trackedEntityId",+ "companyId","createdAt"]},@@ -3207,26 +3208,26 @@"name": "trackedActivityInput","rows": 0,"columns": [- "companyId",- "quantity",- "createdBy",- "trackedActivityId",- "createdAt",+ "updatedBy","trackedEntityId",- "updatedBy"+ "createdAt",+ "trackedActivityId",+ "createdBy",+ "quantity",+ "companyId"]},{"name": "trackedActivityOutput","rows": 0,"columns": [- "trackedEntityId",- "createdBy",- "trackedActivityId",- "updatedBy",- "companyId",+ "createdAt","quantity",- "createdAt"+ "companyId",+ "updatedBy",+ "trackedActivityId",+ "createdBy",+ "trackedEntityId"]},{@@ -3287,13 +3288,13 @@"name": "userModulePreference","rows": 0,"columns": [- "userId",- "hidden",- "id",- "updatedAt","companyId","module",- "position"+ "updatedAt",+ "position",+ "userId",+ "id",+ "hidden"]},{@@ -3325,22 +3326,22 @@"name": "warehouseTransfer","rows": 0,"columns": [- "status",- "createdAt",- "customFields",- "fromLocationId",- "updatedAt",- "toLocationId",- "expectedReceiptDate",- "reference",- "id",- "createdBy",- "transferDate","tags",- "updatedBy","transferId",+ "updatedBy","notes",- "companyId"+ "companyId",+ "id",+ "reference",+ "createdBy",+ "transferDate",+ "toLocationId",+ "fromLocationId",+ "updatedAt",+ "expectedReceiptDate",+ "createdAt",+ "status",+ "customFields"]},{@@ -3374,114 +3375,114 @@"name": "jobOperationBatch","rows": 0,"columns": [+ "processId",+ "companyId",+ "status",+ "workCenterId",+ "updatedBy",+ "updatedAt",+ "readableId","createdBy","notes",- "readableId",- "updatedAt",- "locationId","createdAt","id","customFields",- "status",- "processId",- "companyId",- "updatedBy",- "workCenterId"+ "locationId"]},{"name": "maintenanceSchedule","rows": 0,"columns": [- "estimatedDuration",- "skipHolidays",- "thursday",- "wednesday",- "description","updatedBy",+ "description","workCenterId",- "saturday",- "updatedAt",- "tuesday",- "takesWorkCenterOffline",+ "thursday",+ "wednesday",+ "estimatedDuration",+ "skipHolidays",+ "sunday","frequency","createdBy","friday",- "sunday",- "locationId",- "nextDueAt",- "active",+ "updatedAt",+ "saturday",+ "tuesday",+ "takesWorkCenterOffline",+ "monday","createdAt","name",- "monday",- "procedureId",- "priority",- "companyId",+ "active",+ "locationId",+ "nextDueAt","lastGeneratedAt",- "id"+ "id",+ "companyId",+ "priority",+ "procedureId"]},{"name": "maintenanceDispatch","rows": 0,"columns": [+ "actualEndTime",+ "createdBy",+ "nonConformanceId",+ "createdAt",+ "priority",+ "companyId",+ "plannedStartTime",+ "updatedBy",+ "locationId",+ "status","actualStartTime","content",- "status",- "completedAt","assignee",- "locationId",- "updatedBy",- "createdAt",- "plannedStartTime",- "companyId",- "priority",- "nonConformanceId",- "actualEndTime",- "createdBy",- "maintenanceDispatchId",- "plannedEndTime",- "procedureId",+ "completedAt",+ "source",+ "oeeImpact",+ "id",+ "maintenanceScheduleId",+ "severity",+ "actualFailureModeId","takesWorkCenterOffline","workCenterId",- "suspectedFailureModeId",+ "procedureId","updatedAt",- "maintenanceScheduleId",- "id",- "actualFailureModeId",- "severity",- "source",- "oeeImpact"+ "suspectedFailureModeId",+ "plannedEndTime",+ "maintenanceDispatchId"]},{"name": "maintenanceDispatchComment","rows": 0,"columns": [- "createdBy","updatedBy",- "comment","companyId",- "createdAt",- "id",+ "comment",+ "createdBy","updatedAt",- "maintenanceDispatchId"+ "maintenanceDispatchId",+ "createdAt",+ "id"]},{"name": "maintenanceDispatchEvent","rows": 0,"columns": [- "createdBy","maintenanceDispatchId","updatedAt",- "endTime",+ "createdBy",+ "createdAt","companyId","id",- "createdAt",- "notes",+ "endTime","employeeId","workCenterId",+ "notes","updatedBy","startTime"]@@ -3490,94 +3491,94 @@"name": "maintenanceDispatchItem","rows": 0,"columns": [- "unitOfMeasureCode",- "updatedAt","itemId","quantity",+ "unitOfMeasureCode",+ "updatedAt",+ "createdAt",+ "companyId",+ "maintenanceDispatchId",+ "unitCost","updatedBy","createdBy",- "id",- "unitCost",- "maintenanceDispatchId",- "createdAt",- "companyId"+ "id"]},{"name": "maintenanceDispatchItemTrackedEntity","rows": 0,"columns": [+ "companyId","createdAt","quantity","trackedEntityId",- "companyId",- "updatedBy",- "maintenanceDispatchItemId","createdBy","id",- "updatedAt"+ "updatedAt",+ "updatedBy",+ "maintenanceDispatchItemId"]},{"name": "maintenanceDispatchWorkCenter","rows": 0,"columns": [- "createdAt",- "id",- "updatedAt",- "maintenanceDispatchId","createdBy","updatedBy","companyId",- "workCenterId"+ "workCenterId",+ "createdAt",+ "id",+ "updatedAt",+ "maintenanceDispatchId"]},{"name": "maintenanceScheduleItem","rows": 0,"columns": [- "companyId",- "updatedBy",- "id",+ "quantity",+ "itemId",+ "createdBy",+ "unitOfMeasureCode",+ "maintenanceScheduleId","updatedAt","createdAt",- "maintenanceScheduleId",- "unitOfMeasureCode",- "createdBy",- "itemId",- "quantity"+ "id",+ "updatedBy",+ "companyId"]},{"name": "peopleAssignment","rows": 0,"columns": [+ "employeeId",+ "updatedAt","shiftId","workCenterId",- "locationId","hours",- "employeeId",- "updatedAt",- "note",- "createdAt",- "overtimeHours",- "companyId",+ "locationId","date",+ "updatedBy","id","createdBy",- "updatedBy"+ "createdAt",+ "note",+ "overtimeHours",+ "companyId"]},{"name": "storageRuleWorkCenterAssignment","rows": 0,"columns": [- "ruleId",- "updatedBy",- "workCenterId","companyId","createdBy",- "createdAt"+ "createdAt",+ "ruleId",+ "workCenterId",+ "updatedBy"]},{@@ -3649,24 +3650,24 @@"name": "warehouseTransferLine","rows": 0,"columns": [- "quantity",- "itemId",- "createdBy",- "customFields",- "fromLocationId",- "notes",- "shippedQuantity",- "updatedAt",- "createdAt",- "updatedBy",- "transferId",- "companyId",- "fromStorageUnitId","toStorageUnitId",+ "fromStorageUnitId",+ "companyId",+ "transferId",+ "updatedBy",+ "receivedQuantity",+ "unitOfMeasureCode","id","toLocationId",- "unitOfMeasureCode",- "receivedQuantity"+ "fromLocationId",+ "customFields",+ "quantity",+ "createdBy",+ "itemId",+ "createdAt",+ "updatedAt",+ "shippedQuantity",+ "notes"]},{@@ -3686,30 +3687,30 @@"name": "workCenterReplacementPart","rows": 0,"columns": [- "unitOfMeasureCode","createdBy","itemId","quantity",- "companyId",- "updatedBy",- "id",+ "unitOfMeasureCode","updatedAt","createdAt",- "workCenterId"+ "workCenterId",+ "companyId",+ "updatedBy",+ "id"]},{"name": "workCenterShift","rows": 0,"columns": [- "createdBy",- "shiftId",- "workCenterId",- "updatedBy",- "id",- "createdAt",+ "updatedAt","companyId",- "updatedAt"+ "createdAt",+ "id",+ "updatedBy",+ "workCenterId",+ "shiftId",+ "createdBy"]},{@@ -3803,36 +3804,36 @@"name": "customerItemPriceOverride","rows": 0,"columns": [- "notes",- "createdAt",+ "active",+ "companyId",+ "customerId",+ "updatedBy",+ "validFrom",+ "applyRulesOnTop",+ "id",+ "createdBy","validTo","updatedAt","customerTypeId","itemId",- "validFrom",- "createdBy",- "applyRulesOnTop",- "id",- "companyId",- "active",- "updatedBy",- "customerId"+ "createdAt",+ "notes"]},{"name": "customerItemPriceOverrideBreak","rows": 0,"columns": [- "active",- "overridePrice",- "quantity","createdBy",- "id",- "updatedBy",- "companyId",- "customerItemPriceOverrideId",+ "quantity",+ "overridePrice",+ "active",+ "createdAt","updatedAt",- "createdAt"+ "customerItemPriceOverrideId",+ "companyId",+ "updatedBy",+ "id"]},{@@ -3909,17 +3910,17 @@"name": "customerTax","rows": 0,"columns": [- "taxExemptionReason",- "companyId",- "customerId",- "updatedBy",+ "eori",+ "vatNumber",+ "taxExemptionCertificateNumber",+ "taxExempt",+ "taxId","taxExemptionCertificatePath","updatedAt",- "taxId",- "taxExempt",- "taxExemptionCertificateNumber",- "vatNumber",- "eori"+ "customerId",+ "companyId",+ "updatedBy",+ "taxExemptionReason"]},{@@ -3944,14 +3945,14 @@"name": "nonConformanceCustomer","rows": 0,"columns": [- "updatedAt",- "companyId","customerId",+ "companyId",+ "updatedAt","createdAt",- "updatedBy","nonConformanceId",- "createdBy",- "id"+ "updatedBy",+ "id",+ "createdBy"]},{@@ -4053,16 +4054,16 @@"name": "nonConformanceSalesOrderLine","rows": 0,"columns": [+ "salesOrderReadableId",+ "createdAt",+ "salesOrderId",+ "salesOrderLineId","companyId",- "updatedAt","id",+ "updatedAt","createdBy","updatedBy",- "nonConformanceId",- "salesOrderReadableId",- "createdAt",- "salesOrderLineId",- "salesOrderId"+ "nonConformanceId"]},{@@ -4300,15 +4301,15 @@"name": "fulfillment","rows": 0,"columns": [- "salesOrderLineId",- "createdBy",- "id",- "updatedBy","companyId",- "quantity",- "type",+ "updatedBy",+ "id",+ "createdBy",+ "salesOrderLineId",+ "jobId","createdAt",- "jobId"+ "type",+ "quantity"]},{@@ -4415,138 +4416,144 @@"name": "capacityReservation","rows": 0,"columns": [- "scenarioId",- "id",- "createdAt",- "jobId",+ "endAt",+ "createdBy","workHours","updatedAt","companyId",- "endAt",- "createdBy",- "operationId",- "updatedBy",- "scheduleNote",- "isPlaceholder",- "earliestStartAt",- "resourceKind",+ "jobId",+ "id",+ "scenarioId",+ "createdAt",+ "startAt","resourceId",+ "resourceKind",+ "earliestStartAt","jobOperationBatchId",- "startAt"+ "scheduleNote",+ "isPlaceholder",+ "operationId",+ "updatedBy"]},{"name": "gauge","rows": 0,"columns": [+ "updatedBy","serialNumber","calibrationIntervalInMonths","createdBy",- "updatedBy","locationId","updatedAt","companyId",- "createdAt",- "customFields","supplierId","nextCalibrationDate","modelNumber",+ "createdAt",+ "customFields","dateAcquired","lastCalibrationStatus",- "gaugeRole","gaugeCalibrationStatus","id",+ "gaugeRole","description",+ "storageUnitId","lastCalibrationDate","gaugeId",- "storageUnitId",- "gaugeStatus",- "gaugeTypeId"+ "gaugeTypeId",+ "gaugeStatus"]},{"name": "gaugeCalibrationRecord","rows": 0,"columns": [- "notes",- "companyId",- "temperature",- "gaugeId",- "updatedAt",- "requiresAdjustment","customFields","id","createdAt",- "requiresRepair",- "updatedBy",+ "requiresAdjustment",+ "temperature",+ "updatedAt",+ "gaugeId",+ "notes",+ "companyId",+ "requiresAction",+ "createdBy",+ "calibrationAttempts",+ "supplierId",+ "humidity","dateCalibrated",+ "updatedBy","inspectionStatus",- "approvedBy","measurementStandard",- "humidity",- "supplierId",- "createdBy",- "calibrationAttempts",- "requiresAction"+ "approvedBy",+ "requiresRepair"]},{"name": "inspection","rows": 0,"columns": [- "status",- "notes",- "aql",- "sourceDocument",- "createdAt",- "supplierId",- "dispositionedBy",+ "companyId","acceptanceNumber","sourceDocumentReadableId",+ "dispositionedBy","itemId",- "companyId",- "updatedBy","codeLetter",+ "updatedBy","dispositionedAt","inspectionLevel",+ "aql",+ "status",+ "notes",+ "sourceDocument",+ "supplierId",+ "createdAt",+ "samplingStandard",+ "id",+ "sampleSize",+ "inspectionDocumentId",+ "itemReadableId",+ "updatedAt",+ "severity","inspectionId","rejectionNumber",- "severity",- "samplingPlanType",- "createdBy",+ "sourceDocumentId","lotSize","sourceDocumentLineId",- "sourceDocumentId",- "inspectionDocumentId",- "sampleSize",- "id",- "samplingStandard",- "updatedAt",- "itemReadableId"+ "samplingPlanType",+ "createdBy"]},{"name": "inspectionSample","rows": 0,"columns": [- "inspectedAt",- "trackedEntityId",- "status",- "notes",- "updatedBy",- "companyId",- "createdBy",- "inspectionId","inspectedBy",+ "updatedAt","createdAt","id",- "updatedAt"+ "createdBy",+ "companyId",+ "inspectionId",+ "notes",+ "updatedBy",+ "inspectedAt",+ "trackedEntityId",+ "status"]},{"name": "inspectionMeasurement","rows": 0,"columns": [+ "value",+ "createdAt",+ "notes",+ "inspectionFeatureId",+ "inspectionSampleId",+ "updatedAt","status","createdBy","id",@@ -4554,31 +4561,25 @@"companyId","inspectedBy","updatedBy",- "inspectionId",- "value",- "createdAt",- "notes",- "inspectionFeatureId",- "updatedAt",- "inspectionSampleId"+ "inspectionId"]},{"name": "inspectionSamplingPlan","rows": 0,"columns": [- "updatedBy",- "createdBy",- "id",- "rejectionNumber",- "inspectionId","createdAt","companyId",- "acceptanceNumber",- "updatedAt",- "inspectionFeatureId",+ "inspectionId",+ "rejectionNumber",+ "updatedBy",+ "id",+ "createdBy",+ "codeLetter","sampleSize",- "codeLetter"+ "inspectionFeatureId",+ "acceptanceNumber",+ "updatedAt"]},{@@ -4598,22 +4599,22 @@"name": "inspectionHistory","rows": 0,"columns": [- "outcome",- "samplingStandard",- "createdBy",- "supplierId",- "createdAt",- "itemId",- "inspectionLevel",- "id",- "lotSize",- "defectsFound",- "severity",- "updatedBy","inspectionId","companyId",+ "updatedBy",+ "sampleSize","aql",- "sampleSize"+ "defectsFound",+ "lotSize",+ "id",+ "severity",+ "createdAt",+ "itemId",+ "supplierId",+ "inspectionLevel",+ "outcome",+ "samplingStandard",+ "createdBy"]},{@@ -4700,29 +4701,29 @@"name": "stockTransferLine","rows": 0,"columns": [- "fromStorageUnitId",+ "stockTransferId",+ "requiresSerialTracking",+ "createdBy",+ "quantity","trackedEntityId","id","pickedQuantity",- "quantity",- "requiresSerialTracking",- "stockTransferId",- "createdBy",- "createdAt",- "updatedAt",- "itemId",- "requiresBatchTracking",- "toStorageUnitId",+ "fromStorageUnitId","updatedBy","jobMaterialId","companyId",- "jobId"+ "jobId",+ "toStorageUnitId",+ "requiresBatchTracking",+ "itemId",+ "updatedAt",+ "createdAt"]},{"name": "jobMaterialStep","rows": 0,- "columns": ["jobMaterialId", "jobOperationStepId", "quantity"]+ "columns": ["quantity", "jobOperationStepId", "jobMaterialId"]},{"name": "jobOperation",@@ -4784,26 +4785,26 @@"name": "jobOperationDependency","rows": 0,"columns": [- "operationId",- "dependsOnId","createdAt","jobId",- "companyId"+ "companyId",+ "operationId",+ "dependsOnId"]},{"name": "jobOperationParameter","rows": 0,"columns": [- "updatedBy",- "id",- "createdAt",+ "operationId",+ "value",+ "createdBy",+ "companyId","key","updatedAt",- "companyId",- "value",- "operationId",- "createdBy"+ "id",+ "updatedBy",+ "createdAt"]},{@@ -4825,39 +4826,39 @@"name": "nonConformanceJobOperation","rows": 0,"columns": [- "jobReadableId",- "jobId",- "jobOperationId","createdAt",- "id",- "updatedAt",- "companyId",- "nonConformanceId",+ "jobOperationId",+ "jobId",+ "jobReadableId",+ "updatedBy","createdBy",- "updatedBy"+ "nonConformanceId",+ "companyId",+ "updatedAt",+ "id"]},{"name": "pickingListLine","rows": 0,"columns": [- "toStorageUnitId","id",+ "toStorageUnitId","itemId",+ "updatedBy","pickingListId","companyId",- "updatedBy",- "storageUnitId","quantityPicked",+ "storageUnitId","status","jobOperationId","updatedAt","createdAt",- "customFields",- "quantityReturned","jobId","createdBy","jobMaterialId",+ "customFields",+ "quantityReturned","quantityToPick"]},@@ -4865,11 +4866,11 @@"name": "pickingListLineTrackedEntity","rows": 0,"columns": [- "pickingListLineId","trackedEntityId",- "companyId",+ "pickingListLineId",+ "quantity","quantityPicked",- "quantity"+ "companyId"]},{@@ -4919,124 +4920,124 @@"name": "jobOperationNote","rows": 0,"columns": [+ "createdAt",+ "updatedBy","companyId","note",- "updatedBy",- "createdAt",- "jobOperationId",- "updatedAt",+ "createdBy","id","productionQuantityId",- "createdBy"+ "updatedAt",+ "jobOperationId"]},{"name": "rework","rows": 0,"columns": [- "triggeredAtJobOperationId",- "targetJobOperationId","reason","updatedAt",- "jobId",- "requestedById",- "companyId",- "completedAt",- "id",+ "targetJobOperationId",+ "triggeredAtJobOperationId",+ "quantity","createdAt",- "quantity"+ "id",+ "completedAt",+ "companyId",+ "requestedById",+ "jobId"]},{"name": "jobOperationStep","rows": 0,"columns": [+ "updatedAt",+ "companyId",+ "name",+ "minValue",+ "listValues",+ "id",+ "maxValue",+ "fileTypes",+ "type",+ "required",+ "createdAt",+ "nonConformanceActionId",+ "description",+ "unitOfMeasureCode",+ "sortOrder","nonConformanceInvestigationId","operationId",- "sortOrder",- "updatedBy","assemblyInstructionStepId","createdBy",- "description",- "nonConformanceActionId",- "required",- "createdAt",- "unitOfMeasureCode",- "fileTypes",- "id",- "maxValue",- "type",- "name",- "companyId",- "updatedAt",- "listValues",- "minValue"+ "updatedBy"]},{"name": "jobOperationStepRecord","rows": 0,"columns": [- "createdBy",- "updatedBy",- "value",- "companyId",- "updatedAt",+ "userValue",+ "index",+ "booleanValue",+ "numericValue",+ "createdAt","jobOperationStepId",+ "updatedAt","id",- "createdAt",- "numericValue",- "booleanValue",- "userValue",- "index"+ "companyId",+ "value",+ "createdBy",+ "updatedBy"]},{"name": "jobOperationStepSlide","rows": 0,"columns": [- "annotations",- "sortOrder",- "createdBy",- "imagePath",- "caption",- "companyId","size","updatedBy","id",+ "companyId",+ "modelUploadId",+ "stepId","updatedAt","createdAt",- "stepId",- "modelUploadId"+ "sortOrder",+ "annotations",+ "imagePath",+ "caption",+ "createdBy"]},{"name": "jobOperationToolStep","rows": 0,- "columns": ["jobOperationStepId", "jobOperationToolId"]+ "columns": ["jobOperationToolId", "jobOperationStepId"]},{"name": "kanban","rows": 0,"columns": [- "completedBarcodeOverride","updatedBy",- "createdAt",+ "completedBarcodeOverride","locationId",+ "createdAt","supplierId",- "jobId","fromStorageUnitId",- "quantity",+ "jobId","replenishmentSystem","updatedAt",+ "quantity","storageUnitId","companyId",- "id","conversionFactor",+ "id","autoRelease","purchaseUnitOfMeasureCode",- "itemId","createdBy",+ "itemId","autoStartJob"]},@@ -5044,31 +5045,31 @@"name": "memo","rows": 0,"columns": [- "postingDate",- "updatedAt",- "exchangeRate","postedAt",- "reference","memoId",- "supplierId",- "customFields",- "id",+ "reference",+ "postingDate",+ "exchangeRate",+ "updatedAt","currencyCode",+ "id","amount",- "updatedBy",- "memoDate",- "status",+ "supplierId",+ "customFields","direction","notes",- "voidedBy",+ "status","voidedAt",- "journalId",- "createdBy",- "postedBy",+ "voidedBy",+ "memoDate",+ "updatedBy","createdAt",- "customerId",+ "reasonAccount","companyId",- "reasonAccount"+ "customerId",+ "postedBy",+ "journalId",+ "createdBy"]},{@@ -5142,58 +5143,58 @@"name": "methodOperationParameter","rows": 0,"columns": [+ "value",+ "operationId",+ "createdBy",+ "companyId","key","updatedAt",- "id","updatedBy",- "createdAt",- "operationId",- "value",- "createdBy",- "companyId"+ "id",+ "createdAt"]},{"name": "methodOperationStep","rows": 0,"columns": [+ "sortOrder",+ "operationId",+ "createdBy",+ "updatedBy","assemblyInstructionStepId","description","createdAt","required","unitOfMeasureCode",- "sortOrder",- "operationId",- "createdBy",- "updatedBy",+ "fileTypes",+ "maxValue",+ "id",+ "type","companyId","name","updatedAt","listValues",- "minValue",- "fileTypes",- "maxValue",- "id",- "type"+ "minValue"]},{"name": "methodOperationStepSlide","rows": 0,"columns": [- "annotations","sortOrder",- "createdBy",- "imagePath",+ "annotations","caption",- "companyId",- "updatedBy",+ "imagePath",+ "createdBy","id",+ "updatedBy","size",- "createdAt",- "updatedAt",+ "companyId",+ "modelUploadId","stepId",- "modelUploadId"+ "createdAt",+ "updatedAt"]},{@@ -5214,20 +5215,20 @@{"name": "methodOperationToolStep","rows": 0,- "columns": ["methodOperationStepId", "methodOperationToolId"]+ "columns": ["methodOperationToolId", "methodOperationStepId"]},{"name": "nonConformanceActionProcess","rows": 0,"columns": [- "updatedBy",- "actionTaskId",- "createdBy",- "id",+ "createdAt","updatedAt",- "processId","companyId",- "createdAt"+ "processId",+ "createdBy",+ "id",+ "updatedBy",+ "actionTaskId"]},{@@ -5235,8 +5236,8 @@"rows": 0,"columns": ["assignee",- "updatedAt","status",+ "updatedAt","supplierId","updatedBy","createdAt",@@ -5248,8 +5249,8 @@"actionTypeId","completedDate","companyId",- "sortOrder",- "id"+ "id",+ "sortOrder"]},{@@ -5288,48 +5289,48 @@"name": "payment","rows": 0,"columns": [- "customerId",- "bankAccount",- "companyId",- "createdAt",- "journalId",- "createdBy",- "postedBy",- "voidedBy",- "voidedAt",- "paymentType",- "memo",- "status",- "paymentDate",- "updatedBy",- "totalAmount",- "currencyCode",- "id",- "customFields",- "supplierId",+ "postedAt","reference","paymentId",- "postedAt",+ "postingDate","updatedAt","exchangeRate",- "postingDate"+ "id",+ "currencyCode",+ "totalAmount",+ "supplierId",+ "customFields",+ "status",+ "memo",+ "paymentType",+ "voidedBy",+ "voidedAt",+ "updatedBy",+ "paymentDate",+ "createdAt",+ "customerId",+ "companyId",+ "bankAccount",+ "createdBy",+ "journalId",+ "postedBy"]},{"name": "purchaseInvoiceDelivery","rows": 0,"columns": [+ "companyId",+ "incotermLocation","customFields","id",- "incotermLocation",- "companyId",- "locationId",- "updatedAt","incoterm",+ "updatedAt",+ "locationId","supplierShippingCost",+ "updatedBy","shippingMethodId",- "shippingTermId",- "updatedBy"+ "shippingTermId"]},{@@ -5422,15 +5423,15 @@"rows": 0,"columns": ["companyId",- "updatedAt","id",- "updatedBy",+ "updatedAt","createdBy",+ "updatedBy","nonConformanceId","purchaseOrderReadableId","createdAt",- "purchaseOrderLineId",- "purchaseOrderId"+ "purchaseOrderId",+ "purchaseOrderLineId"]},{@@ -5462,24 +5463,24 @@"name": "purchasingRfqSupplier","rows": 0,"columns": [- "supplierId",- "companyId",- "updatedBy","createdAt",- "purchasingRfqId",+ "updatedBy",+ "companyId",+ "supplierId",+ "createdBy","id",- "createdBy"+ "purchasingRfqId"]},{"name": "purchasingRfqToPurchaseOrder","rows": 0,- "columns": ["companyId", "purchaseOrderId", "purchasingRfqId"]+ "columns": ["companyId", "purchasingRfqId", "purchaseOrderId"]},{"name": "purchasingRfqToSupplierQuote","rows": 0,- "columns": ["companyId", "supplierQuoteId", "purchasingRfqId"]+ "columns": ["companyId", "purchasingRfqId", "supplierQuoteId"]},{"name": "quoteMakeMethod",@@ -5534,7 +5535,7 @@{"name": "quoteMaterialStep","rows": 0,- "columns": ["quoteMaterialId", "quoteOperationStepId", "quantity"]+ "columns": ["quantity", "quoteOperationStepId", "quoteMaterialId"]},{"name": "quoteOperation",@@ -5580,56 +5581,56 @@"name": "quoteOperationParameter","rows": 0,"columns": [- "createdAt",- "updatedBy",- "id","updatedAt","key",- "companyId",+ "createdAt",+ "id",+ "updatedBy","createdBy",+ "operationId","value",- "operationId"+ "companyId"]},{"name": "quoteOperationStep","rows": 0,"columns": [- "type",- "fileTypes",- "id",- "maxValue",+ "unitOfMeasureCode",+ "description",+ "required",+ "createdAt",+ "updatedBy",+ "createdBy",+ "operationId",+ "sortOrder","listValues","minValue","name","companyId","updatedAt",- "updatedBy",- "createdBy",- "operationId",- "sortOrder",- "unitOfMeasureCode",- "description",- "required",- "createdAt"+ "type",+ "fileTypes",+ "id",+ "maxValue"]},{"name": "quoteOperationStepSlide","rows": 0,"columns": [- "caption","imagePath",+ "caption","createdBy",- "sortOrder","annotations",- "modelUploadId",+ "sortOrder","stepId",+ "modelUploadId","updatedAt","createdAt","size",- "id","updatedBy",+ "id","companyId"]},@@ -5651,7 +5652,7 @@{"name": "quoteOperationToolStep","rows": 0,- "columns": ["quoteOperationToolId", "quoteOperationStepId"]+ "columns": ["quoteOperationStepId", "quoteOperationToolId"]},{"name": "receiptFixedAssetLine",@@ -5698,138 +5699,138 @@"name": "nonConformanceReceiptLine","rows": 0,"columns": [+ "createdAt","receiptLineId","receiptId",- "createdAt","receiptReadableId",- "nonConformanceId",- "updatedBy","createdBy",+ "updatedBy",+ "nonConformanceId",+ "companyId","updatedAt",- "id",- "companyId"+ "id"]},{"name": "salesInvoice","rows": 0,"columns": [- "companyId",- "totalDiscount",- "currencyCode",- "exchangeRate",- "createdAt",- "dateDue",- "customerReference",- "exchangeRateUpdatedAt",- "createdBy",- "internalNotes",- "opportunityId",- "invoiceCustomerLocationId",- "totalAmount",- "totalTax",- "customerId","locationId","status",- "assignee",- "invoiceCustomerId",- "customFields",- "dateIssued",- "id",- "paymentTermId",- "updatedAt",- "postingDate",- "shipmentId",- "tags",- "invoiceCustomerContactId",- "externalNotes",+ "customerId",+ "totalTax",+ "totalAmount",+ "invoiceCustomerLocationId",+ "opportunityId",+ "internalNotes",+ "createdBy",+ "exchangeRateUpdatedAt",+ "customerReference",+ "dateDue",+ "createdAt",+ "exchangeRate",+ "currencyCode",+ "totalDiscount",+ "companyId",+ "subtotal",+ "datePaid","invoiceId","updatedBy",- "datePaid",- "subtotal"+ "externalNotes",+ "tags",+ "invoiceCustomerContactId",+ "shipmentId",+ "postingDate",+ "updatedAt",+ "paymentTermId",+ "id",+ "dateIssued",+ "customFields",+ "invoiceCustomerId",+ "assignee"]},{"name": "salesInvoiceLine","rows": 0,"columns": [- "locationId",- "companyId",- "itemId",- "addOnCost",- "modelUploadId",- "unitPrice",- "shippingCost",- "sortOrder",- "taxPercent",- "exchangeRate",- "invoiceLineType",- "description",- "createdAt",- "salesOrderId",- "updatedBy",- "accountId",- "unitOfMeasureCode",+ "methodType",+ "internalNotes",+ "id",+ "assetId","opportunityId",+ "unitOfMeasureCode","nonTaxableAddOnCost",- "assetId",- "id",- "internalNotes",- "methodType",- "invoiceId",- "updatedAt",- "storageUnitId",- "setupPrice",+ "customFields",+ "salesOrderLineId","quantity","createdBy","externalNotes",- "salesOrderLineId",- "customFields"+ "setupPrice",+ "updatedAt",+ "invoiceId",+ "storageUnitId",+ "modelUploadId",+ "addOnCost",+ "unitPrice",+ "locationId",+ "companyId",+ "itemId",+ "salesOrderId",+ "accountId",+ "updatedBy",+ "createdAt",+ "description",+ "invoiceLineType",+ "exchangeRate",+ "shippingCost",+ "sortOrder",+ "taxPercent"]},{"name": "salesInvoiceShipment","rows": 0,"columns": [- "customFields",- "id",- "createdBy",- "updatedBy",+ "companyId",+ "locationId",+ "shippingMethodId",+ "incoterm",+ "shippingTermId","createdAt","updatedAt",- "incotermLocation","shippingCost",- "shippingTermId",- "incoterm",- "companyId",- "shippingMethodId",- "locationId"+ "incotermLocation",+ "customFields",+ "createdBy",+ "id",+ "updatedBy"]},{"name": "invoiceSettlement","rows": 0,"columns": [- "targetMemoId",- "writeOffAmount",- "id","targetExchangeRate",- "discountAmount",- "sourceExchangeRate",- "createdAt",+ "id",+ "writeOffAmount",+ "targetMemoId","appliedDate","paymentId",- "createdBy",- "appliedViaPaymentId",+ "createdAt",+ "sourceExchangeRate",+ "discountAmount","targetPurchaseInvoiceId",- "fxGainLossAmount","sourceAmount",- "appliedAmount",- "companyId",- "memoId",- "targetSalesInvoiceId",+ "fxGainLossAmount",+ "createdBy",+ "appliedViaPaymentId","sourcePaymentId",- "updatedBy"+ "updatedBy",+ "targetSalesInvoiceId",+ "memoId",+ "companyId",+ "appliedAmount"]},{@@ -5837,56 +5838,56 @@"rows": 0,"columns": ["serialNumber",+ "createdBy","salesOrderLineId","shipped",- "createdBy",+ "companyId","updatedAt","id",- "companyId",- "shipmentId",+ "createdAt","updatedBy",- "createdAt"+ "shipmentId"]},{"name": "shipmentLine","rows": 0,"columns": [- "fulfillmentId",- "unitPrice",- "companyId",- "createdBy",- "itemId",+ "shippedQuantity",+ "storageUnitId",+ "createdAt",+ "requiresSerialTracking",+ "shipmentId",+ "orderQuantity",+ "locationId",+ "id",+ "unitOfMeasure",+ "outstandingQuantity","requiresBatchTracking","lineId",+ "itemId","updatedBy","updatedAt",- "outstandingQuantity",- "id",- "locationId",- "unitOfMeasure",- "orderQuantity",- "createdAt",- "requiresSerialTracking",- "shipmentId",- "shippedQuantity",- "storageUnitId"+ "companyId",+ "createdBy",+ "unitPrice",+ "fulfillmentId"]},{"name": "nonConformanceShipmentLine","rows": 0,"columns": [- "shipmentReadableId",- "shipmentLineId",- "shipmentId",- "createdAt",- "updatedAt",- "id",- "companyId",- "nonConformanceId",+ "createdBy","updatedBy",- "createdBy"+ "nonConformanceId",+ "companyId",+ "id",+ "updatedAt",+ "createdAt",+ "shipmentId",+ "shipmentLineId",+ "shipmentReadableId"]},{@@ -5961,33 +5962,33 @@"name": "shipment","rows": 0,"columns": [- "shippingMethodId",- "tags",+ "customerId",+ "id",+ "postingDate",+ "externalDocumentId",+ "sourceDocumentReadableId",+ "supplierId",+ "externalNotes",+ "invoiced",+ "shipmentId",+ "trackingNumber",+ "customFields",+ "status",+ "updatedBy",+ "sourceDocumentId",+ "postedBy",+ "createdBy",+ "internalNotes",+ "updatedAt",+ "opportunityId",+ "supplierInteractionId","locationId","assignee","sourceDocument",- "companyId","createdAt",- "opportunityId",- "supplierInteractionId",- "internalNotes",- "updatedAt",- "updatedBy",- "postedBy",- "createdBy",- "sourceDocumentId",- "trackingNumber",- "status",- "customFields",- "externalNotes",- "shipmentId",- "invoiced",- "sourceDocumentReadableId",- "supplierId",- "customerId",- "id",- "postingDate",- "externalDocumentId"+ "companyId",+ "shippingMethodId",+ "tags"]},{@@ -6204,17 +6205,17 @@"name": "supplierPartPrice","rows": 0,"columns": [- "sourceDocumentId",- "unitPrice",- "sourceType",- "createdBy",+ "quantity",+ "updatedAt",+ "createdAt",+ "leadTime","updatedBy","supplierPartId",- "leadTime","companyId",- "quantity",- "createdAt",- "updatedAt"+ "unitPrice",+ "sourceType",+ "createdBy",+ "sourceDocumentId"]},{@@ -6362,51 +6363,51 @@"name": "supplierTax","rows": 0,"columns": [- "taxId",- "taxExemptionCertificatePath",- "updatedAt",+ "taxExempt",+ "taxExemptionCertificateNumber",+ "eori",+ "vatNumber",+ "taxExemptionReason","supplierId","companyId","updatedBy",- "taxExemptionReason",- "eori",- "vatNumber",- "taxExemptionCertificateNumber",- "taxExempt"+ "taxExemptionCertificatePath",+ "updatedAt",+ "taxId"]},{"name": "workflow","rows": 0,"columns": [- "createdAt",+ "nextRunAt",+ "createdBy",+ "updatedAt",+ "companyId","id","canvasState",- "companyId",- "updatedAt",- "createdBy",- "nextRunAt",- "updatedBy",- "ownerId",+ "createdAt",+ "publishedVersionId","description","name",- "publishedVersionId"+ "ownerId",+ "updatedBy"]},{"name": "workflowVersion","rows": 0,"columns": [- "companyId",- "updatedBy","createdBy",- "updatedAt",- "createdAt",- "id",+ "updatedBy",+ "companyId","nodes",- "workflowId",- "versionNumber",+ "id",+ "createdAt",+ "updatedAt","edges",+ "versionNumber",+ "workflowId","formatVersion"]},@@ -6414,66 +6415,66 @@"name": "workflowRun","rows": 0,"columns": [- "eventId",- "isTest",- "error",- "createdAt",- "depth",- "compactedAt",- "startedAt",- "durationMs",- "completedAt",+ "path",+ "rootRunId",+ "companyId",+ "triggerRecordId",+ "status",+ "ownerId",+ "id",+ "statusReason",+ "sourceEventId","workflowId","causedByRunId","workflowVersionId",+ "durationMs",+ "completedAt","triggerTable",- "statusReason",- "ownerId",- "id",- "sourceEventId",- "rootRunId",- "companyId",- "path",- "status",- "triggerRecordId"+ "createdAt",+ "eventId",+ "isTest",+ "error",+ "compactedAt",+ "depth",+ "startedAt"]},{"name": "workflowStepRun","rows": 0,"columns": [- "createdAt",- "detail",- "sequence",- "completedAt",- "runId",- "itemKey",- "branchTaken",- "nodeId",- "compactedAt",- "durationMs",- "companyId",+ "output",+ "id",+ "statusReason",+ "nodeType","startedAt",+ "companyId","error","input","status",- "output",- "id",- "statusReason",- "nodeType"+ "nodeId",+ "branchTaken",+ "durationMs",+ "compactedAt",+ "detail",+ "createdAt",+ "sequence",+ "runId",+ "completedAt",+ "itemKey"]},{"name": "workflowTriggerEvent","rows": 0,"columns": [- "companyId",- "id","origin",- "workflowVersionId",- "workflowId",+ "id",+ "companyId",+ "eventId","createdAt",- "eventId"+ "workflowId",+ "workflowVersionId"]}],