Chapter 1 · Sessions 1 and 2
What the old tool holds, and the tables that replace it
Session 1 counts what your PLM, PDM or bill-of-materials tool holds and costs, from its own reports and your invoices. Session 2 adds the module's thirteen tables to your Foundation schema, frozen by the database once released, with a made-up pump you can check by hand, tried first on the development project.
35 minSteps 1–5About 2 hours 15 minutes hands-on in these two sessionsAbout 7 hours hands-on across six sessions
By the end of this chapter you can
- Map the old tool from its own reports and bills, without estimating anything.
- Say what the module is the system of record for, and what it leaves alone (CAD authoring).
- Have Claude Code add the missing spine tables, then the thirteen plm_ tables with the rules that freeze released data, and the tests that prove them.
- Seed a five-level product, count it by hand, and try the migration and the seed on the development project yourself.
What the module replaces, and what it leaves alone
The module is the system of record for how products are defined and changed: parts and revisions with lifecycle states, multi-level bills of materials (BOMs) with effectivity, the files of each revision, change control from request to order to notice with where-used impact, approved manufacturers and substance declarations. It replaces the PLM, PDM and bill-of-materials tools a business usually rents, such as Siemens Teamcenter, PTC Windchill, Dassault 3DEXPERIENCE (ENOVIA), Arena, Propel, Autodesk Fusion Manage, Duro, OpenBOM and PDXpert [1][2]. It never replaces the design tool: CAD authoring stays where it is, and the module keeps the files CAD produces, one set per revision, with a fingerprint of each.
| Capability | What it does | Tier | Built in this course |
|---|---|---|---|
| Part and revision control | Part numbers, revision schemes, lifecycle states, make, buy or phantom | MVP | Yes (Session 2) |
| Multi-level BOM | Find numbers, quantities, alternates and substitutes; where-used; compare | MVP | Yes (Sessions 2 and 4) |
| Files and vault | Native CAD and neutral formats (STEP, 3MF, PDF, DXF) per revision | MVP | Yes, by fingerprint (Session 2) |
| Change management | ECR, ECO with affected items and where-used impact, signed board approvals, effectivity and disposition, the notice | MVP | Yes (Session 4) |
| Effectivity | Date, serial and lot effectivity; use-up of old stock | STD | Date and serial (Session 4) |
| AML and compliance | Approved manufacturers with lifecycle risk; RoHS, REACH, Prop 65 and PFAS declarations rolled up | STD | Tables and coverage (Sessions 2 and 5) |
| eBOM to mBOM, NPI and APQP gates, requirements, formulation (ISA-88) | Derived manufacturing BOMs, phase gates, trace links, recipes | STD and BIC | Later, the same way |
Parts, revisions, and the one rule
A part is the thing: a pump, a bearing. A revision is one version of its definition: A, then B after a change. The part says which revision is current. Release is the moment a revision becomes something manufacturing and purchasing may depend on, and from then on it never changes.
Session 1: Map the tool you pay for today, from its own reports
45 minutesWhy
The module has to replace real things, not guesses. Counting what the old tool holds from its own reports, and reading the bill from the invoice, means you know exactly which parts, changes and files must come across, and the saving at the end is arithmetic anyone can check. A figure you estimate now becomes a promise you cannot keep later.
Do this
Ask the tool's owner for a sign-in that can run reports, and one design engineer for 30 minutes. Read from the tool's own reports: parts by lifecycle state, revisions, BOMs by view and their deepest level, files by format, changes open and closed, and seats. Read the bill, renewal date and notice period from the invoice or the vendor's account page. Drawings and models are company property: count them, never copy one into the repository. Then:
cd ~/code/acme-platform && git switch main && git pull && claudeI am mapping the product lifecycle (PLM) tool Acme Bottling rents today, so a module on our platform can replace it. I will paste figures I read from the tool's own reports and from our invoices. Never estimate, round or fill in a figure I have not given you: write "not yet read" and who can read it.
On a new branch plm/map, write docs/plm-map.md with these sections:
1. The tool: name, owner (a job), how people sign in, and the export it offers (CSV or API) for parts, BOMs, change history and files.
2. What it holds: parts in total and per lifecycle state; revisions on the busiest part and on a typical one; BOMs by view (engineering, manufacturing, service); the deepest BOM level; files by format (native CAD, STEP, PDF, DXF, 3MF); the revision scheme (letters, numbers or both).
3. Ten real parts: part number, lifecycle state as one of concept, in_design, prototype, released, deprecated, obsolete (the tool's own word beside it), make, buy or phantom, current revision, owner (a job) and how many assemblies use it.
4. Changes: open now; closed in the last 12 months; for ten recent changes the date raised and the date in effect, and the median days between them (our baseline for ECO cycle time). Who approves (jobs) and how: a signature in the tool, or an email.
5. Suppliers and compliance: whether bought parts list approved manufacturers and their part numbers, lifecycle risk (active, NRND, EOL), and where RoHS, REACH, Prop 65 and PFAS declarations are kept.
6. Seats by job: design engineer, change board member, manufacturing engineer, buyer, view only. Flag anyone doing two of these jobs, and any supplier or contractor with access.
7. The bill: yearly amount, renewal date and notice period, as read from the invoice.
8. Workarounds: anything people keep outside the tool (BOM spreadsheets, revision letters in file names, changes agreed by email).
My figures:
<paste what you read, section by section>
Open a pull request titled "PLM map" and show me the link.You will see recreated screen
- Every figure names the report it came from. "Not yet read" is an honest answer; an estimate is not.
- Your baseline for the first measure. Session 6 compares the module against it.
Check it worked
The pull request has one file, docs/plm-map.md, with all eight sections. Every figure names its source; nothing is estimated; the bill is from an invoice or marked not yet read.
If it goes wrong
Claude Code filled in a price, a count or a date you never gave it
Say: Remove every figure I did not give you and mark it not yet read. On our own platform a screen showed savings nobody had measured, labelled as the ledger. A number in the map that nobody read is the same mistake, made earlier.
You cannot see the bill
Write who can (finance, accounts payable, the tool's owner) and ask them. Do not guess: the cancellation in Session 6 is based on this figure.
The tool's lifecycle states do not map onto the six
Write the tool's word beside the nearest of ours, and list it under a heading To settle. Settle it with the design engineer before Session 5: the loader needs one answer for every old state.
The design engineer offers to send you the CAD files
Thank them and decline. The map needs counts, not copies; files come across in Session 6, straight into company storage, by fingerprint.
Session 1: Try the two mistakes, and choose the pilot
15 minutesWhy
The module exists to prevent two failures: a released BOM edited in place, and two revisions effective on the same day. Trying both on the old tool, on a sandbox or demo data only, tells you whether you are protected today and gives the design engineer a reason to care. A pilot family, small but deep, keeps the build honest: every later check runs on parts people really make.
Do this
On a sandbox, demo data or a copy only, never a live released BOM: try to change a quantity on a released BOM, and ask the tool whether two revisions of one part can be effective on the same dates. Then choose a pilot product family of 10 to 20 parts with one assembly at least four levels deep, one bought part with a manufacturer part number, and one change made in the last year. Then:
Add to docs/plm-map.md on the same branch:
9. The two mistakes, tried on <sandbox, demo data or a copy>: editing a released BOM in place did <what happened>; two revisions effective on the same dates did <what happened>. Who would have noticed: <who>.
10. The pilot: <family name>, <number> parts, deepest assembly <part number> at <levels> levels, bought part <part number> with manufacturer part number <MPN>, recent change <change number>. Chosen because <one sentence>. Read by <design engineer's job title> on <date>.
Push to the same pull request.Owner two approves and the pull request merges.
You will see recreated screen
- If the old tool allowed the edit, that is the strongest case for the module. Write it plainly.
- The pilot is the data every later session checks against.
Check it worked
docs/plm-map.md is on main with the two mistakes recorded and the pilot chosen, read by a named job.
If it goes wrong
The only place to try the mistakes is the live tool
Do not. Write "not tried: no sandbox" and ask the vendor for a sandbox or demo tenant. A real released BOM edited by a test is a real defect.
No family has an assembly four levels deep
Choose the deepest you have and write its depth. The seed in Session 2 is five levels deep, so where-used is still tested across five.
Knowledge check
Revision A of a bearing is released and its drawing needs a correction. What is the right move?
The spine first, then the module's thirteen tables
The module keeps no item list, supplier list or file store of its own. It points at shared spine tables: core_item for items, core_party for manufacturers, core_person for people, core_uom for units, core_attachment for files, core_e_signature for signatures, core_event_outbox for the events other modules read, and core_number_sequence for ECR and ECO numbers. If you built another module first, most exist. If not, Step 3 adds what is missing, in its own migration, before the module's tables.
Every table also carries the spine's standard columns (id, tenant_id, created_at, created_by, updated_at, updated_by, row_version, archived_at and ext), not repeated below. Other modules' tables carry site_id in place of tenant_id; the product definition is genuinely company-wide, so the plm_ tables keep the company scope and no site_id, and the shared spine map records that. An arrow (→) is a foreign key. req means required; a list after a colon is the only values allowed. The specification also lists plm_requirement, plm_trace_link, plm_formula and plm_formula_line, which this course leaves for later.
| Table | One row is | Columns |
|---|---|---|
| plm_part | The PLM extension of a spine item | item_id → core_item req, unique; lifecycle_state req: concept, in_design, prototype, released, deprecated, obsolete; revision_scheme req: alpha, numeric, alpha_numeric; make_buy req: make, buy, phantom; current_revision_id uuid (no foreign key); owner_id → core_person; part_class_attributes json |
| plm_part_revision | One revision of a part | part_id → plm_part req; revision_label req; state req: in_work, in_review, released, superseded, obsolete; description; attributes json; released_at ts; released_by_eco_id uuid; cost_rollup money |
| plm_bom | A BOM header for one parent revision and view | parent_revision_id → plm_part_revision req; bom_view req: engineering, manufacturing, service; status req: in_work, released, superseded |
| plm_bom_line | One component line, with its effectivity | bom_id → plm_bom req; find_no int req; child_part_id → plm_part req; revision_rule req: specific, latest_released; child_revision_id → plm_part_revision; qty req; uom_id → core_uom req; ref_designators; effectivity_from date; effectivity_to date; serial_from; serial_to; alternate_group |
| plm_substitute | An approved substitute for a line | bom_line_id → plm_bom_line req; substitute_part_id → plm_part req; priority int req; note |
| plm_manufacturer_part | An approved manufacturer list (AML) entry | part_id → plm_part req; manufacturer_party_id → core_party req; mpn req; status req: approved, preferred, restricted, obsolete; lifecycle: active, nrnd, eol, obsolete, unknown |
| plm_file | A CAD or specification file of a revision | part_revision_id → plm_part_revision req; attachment_id → core_attachment req; file_format req: native_cad, step, iges, stl, 3mf, pdf, dxf, spec, other; cad_system; is_primary bool |
| plm_ecr | An engineering change request | ecr_no req, unique; title req; reason req; requested_by → core_person req; priority req: low, medium, high, urgent; source_type; source_id uuid; status req: open, evaluating, approved, rejected, converted |
| plm_eco | An engineering change order | eco_no req, unique; title req; change_type req: design, bom, document, supplier, cost, compliance; status req: draft, impact_analysis, ccb_review, approved, implemented, cancelled; effectivity_type req: immediate, date, serial, lot, use_up; effective_at date; wip_disposition: use_as_is, rework, scrap, na; stock_disposition: use_as_is, rework, scrap, return, na; field_action: none, on_failure, retrofit, recall; implemented_at ts; quality_change_ref uuid (soft link to M08, no foreign key) |
| plm_eco_ecr_link | One ECR addressed by an ECO | eco_id → plm_eco req; ecr_id → plm_ecr req |
| plm_eco_affected_item | One revision transition in an ECO | eco_id → plm_eco req; part_id → plm_part req; from_revision_id → plm_part_revision; to_revision_id → plm_part_revision; change_description req |
| plm_eco_approval | One change board approval | eco_id → plm_eco req; role req; approver_id → core_person req; decision req: pending, approved, rejected; decided_at ts; signature_id → core_e_signature |
| plm_compliance_declaration | Substance compliance of a part or manufacturer part | part_id → plm_part; manufacturer_part_id → plm_manufacturer_part; regulation req: rohs, reach_svhc, prop65, tsca_pfas, conflict_minerals, other; status req: compliant, non_compliant, exempt, unknown; substances json; evidence_attachment_id → core_attachment; source req: supplier, test, engineering; valid_until date |
Session 2: Check the spine, and add only what is missing
20 minutesWhy
The plm_ tables point at shared spine tables. If one is missing, the module's migration fails; if the module makes its own copy, the business ends up with two item lists that drift apart. Checking first, and adding only what is missing in its own migration, keeps one list of everything and lets other modules reuse it.
Do this
Read docs/SCHEMA-PLAN.md, docs/naming-standard.md and every file in supabase/migrations. Change nothing yet.
The product lifecycle module needs these spine tables and functions:
- core_item (item_no, name, item_type, base_uom_id, status, lot_controlled, serial_controlled), core_uom, core_party (party_type), core_person (display_name, job_role_id, is_active, ext), core_job_role, core_attachment (storage_bucket, storage_path, file_name, sha256, owner_type, owner_id, classification), core_e_signature (signer_id, meaning, record_type, record_id, record_hash, signed_at, auth_method, printed_name, comment), core_comment (owner_type, owner_id, body, author_id), core_number_sequence, core_event_outbox (event_type, aggregate_type, aggregate_id, payload, occurred_at) and core_audit_log;
- core_current_tenant(), core_touch_row(), core_audit_row(), and one number function that issues the next number from core_number_sequence.
Show me a table: each one exists, exists under another name (say which, for example our parts table), or is missing. If an existing table overlaps (our parts table and core_item), propose how they relate and wait for my answer.
When I answer, on a new branch plm/spine, add a section "## M14 Product lifecycle (PLM)" to docs/spine-map.md, the one spine map every module shares (if it does not exist yet, create it with the heading "# Spine map" first; never a separate map file for this module), holding that table and my answers, and saying: "Company-wide: the specification defines products for the whole company, so the plm_ tables carry no site_id (other modules' tables carry site_id in place of tenant_id)." Then write ONE migration (npx supabase migration new plm_spine) that adds only the missing ones, following the naming standard: row-level security on with no policies; the number function security definer with set search_path = '', filtered on core_current_tenant(), and the only thing that updates core_number_sequence. Add pgTAP tests in supabase/tests/plm_spine.test.sql. Do not alter any existing table and do not connect to any Supabase project. Push, open a pull request titled "Spine tables for PLM" with the map and the migration, wait for the schema check and tell me the result in plain words.You will see recreated screen
- The report before any writing. Read it: this is where a second item list would have been born.
- A decision for you. If unsure, ask: what happens to the parts table in five years?
Check it worked
Pull request Spine tables for PLM is green, adds the M14 section to docs/spine-map.md (company-wide recorded), one migration and one test file, and changes no existing table (Files changed lists nothing under an older migration).
If it goes wrong
Claude Code wants to rename or change your parts table
Say: Do not alter any existing table. Propose a link instead. Renames are where half-done work hides: on our platform one rename left three names for the same thing live at once.
It put the spine tables inside a plm_ migration
Say: Move the core_ tables into their own migration, plm_spine, merged first. Other modules will reuse them; they must not depend on PLM being installed.
The schema check is red with relation core_current_tenant does not exist
The function is used before the migration that creates it. Say: Order the migration so functions come before the tables that use them, and run the check again.
Session 2: The thirteen tables, frozen once released, with their tests
30 minutesWhy
One prompt that writes the tables, the rules that freeze released data and the tests that prove each rule means the proof arrives with the change. The rules live in the database, not the screens, so every screen, the loader and any agent that writes to these tables later is held to them. A rule nobody tests is a rule a later change can quietly remove.
Do this
Read docs/naming-standard.md, docs/matrix.json and the spine migration on main.
On a new branch plm/tables, add the tables below under "### Tables" in the M14 section of docs/spine-map.md (never a separate tables file), then ONE migration (npx supabase migration new plm_tables) that creates them. Every table: id uuid primary key; tenant_id default core_current_tenant(), indexed; created_at, created_by, updated_at, updated_by, row_version, archived_at, ext jsonb; row-level security on with no policies; the core_touch_row() and core_audit_row() triggers. req = not null; a list after a colon = a check constraint; qty = numeric(18,6); money = numeric(18,4); ts = timestamptz.
plm_part: item_id -> core_item req, unique per tenant; lifecycle_state req: concept, in_design, prototype, released, deprecated, obsolete; revision_scheme req: alpha, numeric, alpha_numeric; make_buy req: make, buy, phantom; current_revision_id uuid (no foreign key); owner_id -> core_person; part_class_attributes jsonb.
plm_part_revision: part_id -> plm_part req; revision_label text req; state req: in_work, in_review, released, superseded, obsolete; description text; attributes jsonb; released_at ts; released_by_eco_id uuid; cost_rollup money.
plm_bom: parent_revision_id -> plm_part_revision req; bom_view req: engineering, manufacturing, service; status req: in_work, released, superseded.
plm_bom_line: bom_id -> plm_bom req; find_no int req; child_part_id -> plm_part req; revision_rule req: specific, latest_released; child_revision_id -> plm_part_revision; qty qty req; uom_id -> core_uom req; ref_designators text; effectivity_from date; effectivity_to date; serial_from text; serial_to text; alternate_group text.
plm_substitute: bom_line_id -> plm_bom_line req; substitute_part_id -> plm_part req; priority int req; note text.
plm_manufacturer_part: part_id -> plm_part req; manufacturer_party_id -> core_party req; mpn text req; status req: approved, preferred, restricted, obsolete; lifecycle: active, nrnd, eol, obsolete, unknown.
plm_file: part_revision_id -> plm_part_revision req; attachment_id -> core_attachment req; file_format req: native_cad, step, iges, stl, 3mf, pdf, dxf, spec, other; cad_system text; is_primary bool.
plm_ecr: ecr_no text req, unique per tenant; title req; reason req; requested_by -> core_person req; priority req: low, medium, high, urgent; source_type text; source_id uuid; status req: open, evaluating, approved, rejected, converted.
plm_eco: eco_no text req, unique per tenant; title req; change_type req: design, bom, document, supplier, cost, compliance; status req: draft, impact_analysis, ccb_review, approved, implemented, cancelled; effectivity_type req: immediate, date, serial, lot, use_up; effective_at date; wip_disposition: use_as_is, rework, scrap, na; stock_disposition: use_as_is, rework, scrap, return, na; field_action: none, on_failure, retrofit, recall; implemented_at ts; quality_change_ref uuid (no foreign key: the quality module may not be installed).
plm_eco_ecr_link: eco_id -> plm_eco req; ecr_id -> plm_ecr req.
plm_eco_affected_item: eco_id -> plm_eco req; part_id -> plm_part req; from_revision_id -> plm_part_revision; to_revision_id -> plm_part_revision; change_description text req.
plm_eco_approval: eco_id -> plm_eco req; role text req; approver_id -> core_person req; decision req: pending, approved, rejected; decided_at ts; signature_id -> core_e_signature.
plm_compliance_declaration: part_id -> plm_part; manufacturer_part_id -> plm_manufacturer_part; regulation req: rohs, reach_svhc, prop65, tsca_pfas, conflict_minerals, other; status req: compliant, non_compliant, exempt, unknown; substances jsonb; evidence_attachment_id -> core_attachment; source req: supplier, test, engineering; valid_until date.
Rules the database keeps (trigger functions security definer, set search_path = '', filtered on the tenant):
1. A part never has two released revisions (partial unique index). revision_label is unique per part and matches the scheme (letters for alpha, digits for numeric).
2. A revision becomes released only with released_by_eco_id set, or ext baseline true for a first revision. Once released, superseded or obsolete, only state changes: released to superseded or obsolete, superseded to obsolete.
3. A BOM header changes only status (in_work, released, superseded, in that order) and is released only when it has at least one line and every child part has a released revision.
4. No insert, update or delete on plm_bom_line or plm_substitute unless the BOM is in_work; none on plm_file unless the revision is in_work or in_review.
5. revision_rule specific needs child_revision_id. One find number per BOM and start date (unique index with nulls not distinct).
6. Delete is refused on every plm_ table: history is archived with archived_at.
7. Two core_number_sequence rows: plm_ecr prefix ECR-, plm_eco prefix ECO-, padded to 4.
pgTAP tests in supabase/tests/plm_tables.test.sql: every table exists with row-level security on; and the database refuses each of: a changed description on a released revision, a new line on a released BOM, deleting a part, a specific line with no child revision, label B1 on an alpha part, releasing a BOM whose child has no released revision. Add the thirteen tables to docs/matrix.json with no rights yet. Do not connect to any Supabase project.
Push, open a pull request titled "PLM tables", wait for the schema check, and tell me the result in plain words. If it fails, fix it and try again before reporting.You will see recreated screen
- Two released revisions of one part cannot exist, even for an instant.
- The test tries the forbidden edit and passes only if the database refuses it.
Check it worked
Pull request PLM tables is green; the summary counts the tests and names the six refusals; the M14 section of docs/spine-map.md and the matrix rows are in the same pull request.
Fastest path
Asking for the tables, the rules, the tests and the matrix rows in one prompt, with "wait for the check and fix it before reporting", replaces half a dozen rounds of adding one rule at a time.
If it goes wrong
The duplicate find-number test passes when it should fail
Postgres treats two empty values as different, so a unique rule on columns that are often empty never fires. Say: Make the find-number index unique with nulls not distinct, and show me the duplicate test failing before the fix and passing after.
The check is red with relation "core_item" does not exist
The spine pull request is not merged yet. Merge it, then say: Merge origin/main into this branch, push, and wait for the new check.
After merging main into the branch, a rule or its test has gone
We hit this: undoing a batch on main silently removed another branch's schema change, with no conflict reported. Say: I merged main. List every table, rule and test this branch adds and confirm each is still there.
Claude Code reports green but the check on GitHub is red
Say: The schema check is red. Run gh pr checks, read the failed log, fix the cause and wait for green before you report. Trust the check on the pull request, never the summary.
The seed: a pump you can count by hand
Every later check needs numbers you worked out yourself. The seed is a small, made-up pump, five levels deep. The shaft is a phantom: an assembly that is never stocked, so its parts pass straight through to its parent. To find how many of a part one pump needs, multiply the quantities down each branch, then add the branches.
| Question | Answer for one PLM-1000 | Working |
|---|---|---|
| Bearings (PLM-5000) | 3 | 2 through the phantom shaft, plus 1 through the cover |
| Fasteners (PLM-4100) | 12 | 8 on the rotor, plus 4 on the cover |
| Rows in the explosion | 9 | One per BOM line, reaching level 5 when the pump is level 1 |
| Where-used of the bearing | 6 | Shaft, cover, rotor, housing, motor, pump (the pump counts once) |
| Where-used of the fasteners | 5 | Rotor, cover, motor, housing, pump |
Session 2: Seed the pump, then try it all on the development project
25 minutesWhy
A small, made-up product makes every later number checkable by hand, and a test that asserts those numbers from a fixture stops the seed and the later steps drifting apart. Trying the migrations and the seed on the development project yourself, before merge, means production only ever receives what has already run cleanly on a real Supabase project. Seed rows never reach production: the pipeline applies migrations, not seeds.
Do this
On a new branch plm/seed, write supabase/seeds/plm.sql and list it under [db.seed] sql_paths in supabase/config.toml, so CI and scripts/seed-dev load it; never append it to supabase/seed.sql, and the deploy workflow never seeds production. Dates shifted onto today (the dates below become today minus the same whole number of days, keeping their gaps), made-up names only, marked SYNTHETIC (a header saying so, and ext synthetic true on every row), and every insert skipping a row that already exists, so a second run adds nothing:
- unit EA; job roles DESIGN_ENG, CCB_MEMBER, MFG_ENG, BUYER; six people: Seed Design Engineer, Seed Board Engineering, Seed Board Manufacturing, Seed Board Purchasing (ext ccb_function engineering, manufacturing, purchasing), Seed Manufacturing Engineer, Seed Buyer; manufacturers Seed Bearing Works, Seed Bearing Partners, Seed Fastener Works.
- nine items, unit EA, scheme alpha, each with a plm_part owned by Seed Design Engineer: PLM-1000 Pump assembly (make, serial controlled), PLM-2000 Motor assembly, PLM-2100 Housing assembly, PLM-3000 Rotor assembly, PLM-3100 Cover assembly (make), PLM-4000 Shaft assembly (phantom), PLM-4100 Fastener pack, PLM-5000 Bearing (buy), PLM-7000 Pump assembly next generation (make, lifecycle in_design).
- the first eight: revision A inserted in_work with released_at 2026-01-05 (shifted) and ext baseline true, its file attached, then released; it is current and the part is released. PLM-7000: revision A in_work, no current revision.
- six engineering BOMs on revision A, lines latest_released, unit EA, effectivity_from 2026-01-05, released after their lines: PLM-1000: 10 PLM-2000 x1, 20 PLM-2100 x1; PLM-2000: 10 PLM-3000 x1; PLM-2100: 10 PLM-3100 x1; PLM-3000: 10 PLM-4000 x1, 20 PLM-4100 x8; PLM-3100: 10 PLM-5000 x1, 20 PLM-4100 x4; PLM-4000: 10 PLM-5000 x2.
- AML: PLM-5000 Seed Bearing Works SEED-B-6204 preferred active; PLM-5000 Seed Bearing Partners SEED-B-6204X approved nrnd; PLM-4100 Seed Fastener Works SEED-F-100 approved active.
- declarations: PLM-5000 with SEED-B-6204 rohs compliant, source supplier, valid_until 2027-06-30, with an evidence attachment; PLM-5000 reach_svhc unknown, source engineering.
- files: a primary pdf on PLM-5000 A and a primary step on PLM-1000 A, tiny synthetic files with their real sha256.
No ECRs or ECOs.
Write tests/fixtures/plm-counts.json with the hand counts, which the tests read (never fixed dates in seed rows): 9 parts (8 released, 1 in design); 6 make, 1 phantom, 2 buy; 9 BOM lines; one PLM-1000 needs 3 PLM-5000 and 12 PLM-4100; where-used of PLM-5000 is 6 and of PLM-4100 is 5; the explosion of PLM-1000 is 9 rows reaching level 5; 1 of 2 bought parts has a current declaration. Add supabase/tests/plm_seed.test.sql asserting, from tests/fixtures/plm-counts.json, every count that exists in tables now, after the seed has run twice (the where-used and explosion counts are asserted in Session 4).
Push, open a pull request titled "PLM seed", wait for the checks, and tell me the result.When it is green, apply the migrations and the seed to the development project yourself, in a terminal (not inside Claude Code): db push --include-seed loads the new seed file the first time; after that, npm run seed:dev reloads it. Never reset the database. The password is in the password manager as Supabase: acme-platform-dev database password; nothing shows as you paste.
cd ~/code/acme-platform && git switch plm/seed && git pullnpx supabase link --project-ref tsrqponmlkjihgfedcbanpx supabase db push --include-seedhttps://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/editor
The development project's Table Editor: open plm_part.
You will see recreated screen
- Check the reference is tsrqponmlkjihgfedcba, the development project. If it shows abcdefghijklmnopqrst, stop: that is production.
- Only the PLM migrations should be listed. Anything else, answer n and ask why.
You will see recreated screen
| item | lifecycle_state | make_buy | current revision |
|---|---|---|---|
| PLM-1000 | released | make | A |
| PLM-4000 | released | phantom | A |
| PLM-5000 | released | buy | A |
| PLM-7000 | in_design | make | (none) |
- Nine rows. PLM-7000 has no current revision: nothing of it is released yet.
Check it worked
The pull request is green; the development project shows nine parts and nine BOM lines; running the push again applies nothing and adds no rows. Then owner two approves, it merges, and the pipeline applies the migrations (not the seed) to production.
If it goes wrong
The terminal shows the production reference abcdefghijklmnopqrst
Answer n. Run npx supabase link --project-ref tsrqponmlkjihgfedcba again and read the reference before pushing. In this module only the pipeline changes production.
A later check expects a number the seed never made
We hit this in five Academy modules: steps written against counts the seed did not create. Say: List every count tests/fixtures/plm-counts.json promises and the seed line that creates each. Fix the seed, not the check.
Seed rows appear twice in the development project
Say: The seed added duplicates on a second run. Make every insert skip a row that already exists, on its natural key, and add a test that runs the seed twice.
Claude Code offers to run db push for you
Decline. The guard rails from Foundation Session 1 deny it, and the development project's password is yours to type.
Knowledge check
Why does the module have its own migration for missing spine tables, separate from the plm_ tables?
Knowledge check
Where do you first apply a new PLM migration and the seed, and who runs it?
References
- Arena: key PLM capabilities. https://www.arenasolutions.com/what-is-plm/key-plm-capabilities/
- SoftwareConnect: product lifecycle management software comparison. https://softwareconnect.com/product-lifecycle-management/
- PostgreSQL Documentation: Trigger functions (PL/pgSQL). https://www.postgresql.org/docs/current/plpgsql-trigger.html
- PostgreSQL Documentation: Partial indexes. https://www.postgresql.org/docs/current/indexes-partial.html
- Supabase Docs: Seeding your database. https://supabase.com/docs/guides/local-development/seeding-your-database
- Supabase CLI reference: supabase db push. https://supabase.com/docs/reference/cli/supabase-db-push
Chapter 2 · Sessions 3 and 4
Who may do what, the screens, and one change end to end
Session 3 writes the four PLM roles into your role matrix, generates the access rules from it and builds three screens on top. Session 4 builds where-used, the revision resolver and the change guards, then walks one change from request to signed release, with every refusal tested.
40 minSteps 6–10About 2 hours 50 minutes hands-on in these two sessions
By the end of this chapter you can
- Add the four roles and five machine accounts to docs/matrix.json, and generate and test the access rules.
- Build the three screens behind the default-deny sign-in, and pass the phone check.
- Prove where-used, the explosion and the resolver against your hand counts.
- Walk one change from ECR to released revision B, and prove an ECO cannot be implemented without every signature.
Four jobs, five machine accounts
Product definitions belong to the whole company, not one site, so these rights cover every plm_ row of your company. Nobody gets delete: records are archived, never removed. Remember how Postgres applies a right: an update only finds rows the role can read, and the changed row must still pass the read rule, so each role reads every status of what it updates [1].
| Role (job, not person) | Its job in the module | Screens |
|---|---|---|
| design_engineer | Parts, in-work revisions, engineering and service BOMs, files; raises ECRs and ECOs, records impact, submits and releases. Never sets released itself | /plm/parts, /plm/changes, /plm/bom |
| ccb_member | Decides ECRs; signs or rejects only their own pending approval; one each for engineering, manufacturing and purchasing | /plm/changes (signs), /plm/bom |
| mfg_engineer | Manufacturing BOMs; an ECO's effectivity, work-in-progress disposition and field action | /plm/parts, /plm/changes, /plm/bom |
| buyer | Approved manufacturers and declarations; an ECO's stock disposition; sees released BOMs only | /plm/changes, /plm/bom |
| eco-submit, eco-release | Machine accounts behind /api/plm/submit and /api/plm/release: open the board review; release and implement | None |
| plm-loader, plm-resolve, plm-check | Insert-only import through import-plm.yml (set NOLOGIN at cut-over); read-only revision answers for MRP and MES; read-only checks. Each signs in with its own password, set by a person and named in docs/KEYS.md | None |
Some rules cannot be a single cell. They are restrictive rules: a row must pass them as well as any rule that grants a right, so no other grant gets around them. The creator of an ECO cannot approve it; the requester of an ECR cannot decide it; one person holds at most one approval on an ECO; only eco-release sets a revision to released; only plm-loader writes the baseline or imported flags.
Session 3: The roles into the matrix, the rules generated, tested both ways
35 minutesWhy
Every access rule in the platform is generated from docs/matrix.json, so a right written there is enforced by the database for every screen, route and import, and a right missing there refuses the learner in the middle of the change flow next week. Writing the rights walk now, every action Sessions 4 to 6 need, with a test that each has a cell, finds those gaps today instead of mid-change.
Do this
Read docs/matrix.json, scripts/gen-policies.mjs, supabase/tests/access.test.sql and the M14 section of docs/spine-map.md.
On a new branch plm/access, add the product lifecycle roles to docs/matrix.json, following exactly how the matrix already names roles, scopes and rights. Product definitions are company-wide, so the scope is every plm_ row of our company, not one site. Nobody gets delete.
- design_engineer: insert core_item (draft) and plm_part (concept, in_design); update parts while concept, in_design or prototype (never to released, deprecated or obsolete); insert and edit in_work and in_review revisions, in_work engineering and service BOMs, their lines and substitutes, and files on in_work or in_review revisions; insert plm_ecr as themselves; move ECRs open to evaluating and approved to converted; insert plm_eco (draft), links and affected items, and edit them while draft or impact_analysis; record impact in plm_eco.ext; cancel an ECO in ccb_review or approved with a core_comment saying why.
- ccb_member: move ECRs evaluating to approved or rejected; update only their own pending plm_eco_approval row (decision, decided_at, signature_id); insert core_e_signature as themselves; move an ECO ccb_review to approved or cancelled; insert core_event_outbox of type plm.eco.approved only.
- mfg_engineer: in_work manufacturing BOMs and their lines; on an ECO in draft or impact_analysis only effectivity_type, effective_at, wip_disposition, field_action.
- buyer: plm_manufacturer_part, plm_compliance_declaration, core_party (manufacturer, supplier), evidence attachments; on an ECO in draft or impact_analysis only stock_disposition; read BOMs only when released or superseded.
- All four: read what they act on in every status; insert plm_ecr as themselves; insert core_comment; call the number function for plm_ecr (design_engineer also for plm_eco).
- Machine accounts: eco-submit (insert pending plm_eco_approval, move ECO impact_analysis to ccb_review); eco-release (release revisions and BOMs, set current revision and lifecycle, ECO approved to implemented, outbox plm.part.released and plm.eco.implemented); plm-loader (insert only, plus the one import release function); plm-resolve and plm-check (read only). Each machine account signs in with its own password, set by a person and listed by name in docs/KEYS.md, never the service key.
- Restrictive rules: ECO creator cannot approve it; ECR requester cannot decide it; one approval per person per ECO; only eco-release sets released_by_eco_id; only plm-loader writes ext baseline or imported; approvals are inserted only by eco-submit.
Run node scripts/gen-policies.mjs to regenerate the access-rule migration. Add tests in supabase/tests/plm_access.test.sql with one allowed and one refused case per role and table, plus each restrictive rule, allowed inserts inside a transaction that is rolled back. For an update, check the row really changed, not only that no error came back.
Then write docs/rights-walk.md, one line per action of the change flow: buyer raises ECR; design_engineer moves it to evaluating; ccb_member approves it; design_engineer creates ECO, link, affected item, revision B and its file; design_engineer runs where-used (reads plm_bom_line, plm_bom, plm_part_revision, plm_part, core_item) and records impact; mfg_engineer sets effectivity; buyer sets stock disposition; eco-submit opens the review; each ccb_member signs; the last signer moves the ECO to approved and writes plm.eco.approved; eco-release releases B and writes two events; plm-loader imports (Sessions 5 and 6); plm-check reads every plm_ table. Add a test that fails if a line has no matching cell, skipping lines marked retired.
If the matrix cannot express a rule, stop and tell me which before writing anything around it. Push, open a pull request titled "PLM access rules", wait for the checks and tell me the result.You will see recreated screen
- The buyer may set stock_disposition, and only while the ECO is still being drafted.
- Refused and allowed are both tested. A test that only checks refusals passes even when nothing is allowed.
Check it worked
Pull request PLM access rules is green; the access tests include the six restrictive rules; docs/rights-walk.md has a line for every action in the change flow and its test passes.
If it goes wrong
A Publish or Sign button reports success but nothing changes
We hit this in three Academy modules: an update only finds rows the role can read, and the changed row must still pass the read rule. Say: For each role that updates this table, make its read rule cover the row before and after the change, and add a test that the row really changed.
The "policies" or "rights-walk" check fails though your change looks right
It compares a generated list with the code. Say: Open the failing check's log, regenerate the list it compares against, commit it, and show me what changed. If the new list shows an unprotected table, stop.
Claude Code loosened a test to make it pass
Say: Never edit, skip or loosen a test or a check to get to green. Put it back, and explain why you think it is wrong; I will decide.
Session 3: Three screens, behind the default-deny sign-in
35 minutesWhy
The screens are where people meet the rules. Building them on the access rules and the route list generated from the matrix means a screen cannot show what the database would refuse, and a signed-out request is refused by the platform's single gate. Testing them at phone width now matters because a board member will sign on a phone between meetings.
Do this
Read node_modules/next/dist/docs/ first: this Next.js version differs from older guides, and request middleware lives in proxy.ts. Then read proxy.ts, lib/access/routes.ts, docs/matrix.json and the existing supervisor screens.
On a new branch plm/screens, add three screens. List each in docs/matrix.json with its roles and regenerate lib/access/routes.ts with scripts/gen-routes.mjs, so the existing default-deny refuses a signed-out request and any role not listed:
1. /plm/parts (design_engineer; mfg_engineer for manufacturing BOMs): parts with lifecycle state; one part with its revisions, files and BOMs; edit only an in_work revision and an in_work BOM. A released revision is read-only and says "Change by ECO".
2. /plm/changes (all four roles): ECRs and ECOs by status; one ECO with affected items, effectivity, dispositions, the recorded impact and its approvals. A Sign button only on the signed-in member's own pending row.
3. /plm/bom (all four roles): the released BOM one level at a time (find number, part number, name, quantity, unit, revision rule); tap a child to go down; a date box that starts at today; no edit control anywhere.
Every read and write uses the signed-in person's session, never the secret key, and the author of anything saved comes from the session, never from the page. On a phone, show each BOM line as a stacked card. If a value is not stored, show "No data", never a made-up number.
Add screen tests at 360 and 390 px (no sideways scroll, 44 px tap targets, 16 px fields) and, per screen, a signed-out request landing on sign-in and a refused role. Push, open a pull request titled "PLM screens", wait for the checks, and give me the preview link.Open the preview on your phone. Then sit the design engineer at /plm/parts and a board member at /plm/changes on a phone, and do not explain. Write down where each stops or asks.
You will see recreated screen
- The date decides which revision answers. Session 4 points this at the resolver.
- No edit control, for any role. The rule is in the database too.
You will see recreated screen
- If it writes a middleware.ts file instead, stop it: this version uses proxy.ts.
Check it worked
The pull request is green with the phone and refused-role tests; the preview opens on your phone; you have the design engineer's and board member's notes.
If it goes wrong
Claude Code creates middleware.ts
Say: Read node_modules/next/dist/docs/ for this version. Request middleware is proxy.ts here; use the existing one.
A link on the new screens opens a blank 404
We hit this: a link that compiles is not a link that resolves. Say: Open every page and every link on the three screens as each role and list every 404 or error.
The ECO page shows a cost or a date nobody entered
Say: Find where this value comes from. If it is not stored, show No data. Our platform once showed a chart graded "In control" from twelve made-up points.
The preview asks you to sign in to Vercel
That is Vercel's deployment protection on previews, not your code. Sign in with your team account.
Knowledge check
The buyer may set stock_disposition on an ECO. Why must the buyer's read rule cover the ECO too?
Where-used, the explosion, and which revision applies
Where-used reads the BOM upward: every assembly that contains a part, at every level above it. It is the question behind every change. The query climbs one level at a time (a recursive query) and must never step into a part already on its path, so a loop in the data is reported, not followed forever [2].
Effectivity says which revision applies on a date or for a serial number. The module stores only the date each revision starts; the next start ends the previous one, so exactly one revision answers every day. MES and MRP ask the resolver, and it either returns one revision or refuses.
| Effectivity rule | In plain words |
|---|---|
| Start of a revision | The ECO's effective_at for date and use_up; otherwise the day it was implemented. A baseline revision applies from the beginning |
| Who can answer | Only released, superseded and obsolete revisions; never one in_work or in_review |
| Serial | The ECO's ext holds first_serial (fixed width, such as S-0100); a unit at or above it gets the new revision |
| Lot | Stored, but this course resolves a lot ECO from the day it was implemented |
| Refused before implementing | An effective date on or before the start of the revision being replaced; two revisions starting the same day; date and serial effectivity mixed on one part |
Session 4: Where-used, the explosion and the resolver, proven against your hand count
30 minutesWhy
These three functions are what every other module will trust: MRP explodes BOMs, MES asks which revision to build, and every change starts with where-used. A function checked only by the program that wrote it is a guess. Checking it against the counts you did by hand in Session 2, and showing each test fail when the function is broken, is what makes the answer trustworthy.
Do this
Read the M14 section of docs/spine-map.md and tests/fixtures/plm-counts.json.
On a new branch plm/resolve, write docs/effectivity-rules.md with these rules: a revision applies from its start until the next revision's start; only released, superseded and obsolete revisions answer; a baseline revision applies from the beginning; the start is the ECO's effective_at for date and use_up, otherwise the day the ECO was implemented; for serial effectivity the ECO's ext holds first_serial (fixed width, such as S-0100) and a unit at or above it gets the new revision; a query with no serial uses the implemented day; lot ECOs start on the implemented day. Line effectivity applies to explosions only: skip a line whose effectivity_from is after the date, whose effectivity_to is before it, or whose serial range excludes the serial; empty bounds do not limit.
Then a migration (npx supabase migration new plm_resolve) with four functions that run with the caller's rights (security invoker):
1. plm_where_used(part_id): one row per distinct ancestor at its nearest level, with the path; stops with an error naming the part if a part is its own ancestor; flags a row when a line on the way up is revision_rule specific.
2. plm_resolve_revision(part_id, as_of date, serial text default null): exactly one revision, or an error when there are none or two.
3. plm_explode(part_id, as_of date, serial text default null): the indented BOM with level, quantity multiplied down each branch, unit and each child's resolved revision.
4. plm_bom_compare(part_id, date_a, date_b): one row per line whose revision or quantity differs, or that exists on one date only.
pgTAP tests in supabase/tests/plm_resolve.test.sql, on the seed: where-used of PLM-5000 is 6 and of PLM-4100 is 5; PLM-1000 explodes to 9 rows reaching level 5, needing 3 PLM-5000 and 12 PLM-4100. And on a throwaway fixture in a rolled-back transaction: a part with revisions A (baseline), B (effective 2026-03-01) and C (2026-06-01), checked the day before, on and after each start; a part with serial effectivity from S-0100, where S-0099 gets A and S-0100 gets B; a loop that where-used reports instead of following. For each test, show me it failing with the function deliberately broken, then passing.
Push, open a pull request titled "PLM where-used and resolver", wait for the checks, and tell me the result.You will see recreated screen
- Red first, on purpose. A test that has never failed may be unable to.
- The function's answers are checked against your hand count, not against itself.
Check it worked
The pull request is green; the summary's numbers match tests/fixtures/plm-counts.json exactly; each test was shown failing once; you have applied it to the development project by the routine after Step 5.
If it goes wrong
Where-used of the bearing says 7, not 6
The pump is reached by two routes and was counted twice. Say: Return each ancestor once, at its nearest level, and keep the test at 6. The hand count is right; the function is wrong.
A test passes whatever the function does
We hit this: a test that checks a name is present, or a runner that always exits successfully, can never fail. Say: Break the function on purpose, run the test, and show me it fails.
The where-used query never finishes
A part is its own ancestor somewhere. Say: Carry the path and refuse to climb into a part already on it; report the loop with the part number.
A change, end to end
Session 4: The change guards and the three routes
35 minutesWhy
The promise that an ECO cannot be implemented without every signature has to hold even when someone skips the screen. Guards in the database refuse a wrong status move whoever attempts it, and they check the approvals again at the last step. The routes then do the steps no person may do by hand: open the board's review, sign with a fingerprint of what was approved, and release in one transaction so nothing is announced that did not happen.
Do this
Read node_modules/next/dist/docs/ for route handlers in this Next.js version, then the M14 section of docs/spine-map.md, docs/effectivity-rules.md and docs/matrix.json.
On a new branch plm/change-flow:
1. A migration (npx supabase migration new plm_change_guards) with triggers, security definer, set search_path = '', filtered on the tenant:
a. plm_eco status moves only draft, impact_analysis, ccb_review, approved, implemented; draft to ccb_review and approved may go to cancelled; implemented and cancelled never change.
b. Into ccb_review needs: at least one affected item, every to-revision in_review, all three dispositions set, effective_at when the type is date or use_up, an impact key in ext, and at least one approval row.
c. After ccb_review the ECO's fields, links and affected items cannot change (except plm-loader inserting affected items under an ECO whose ext has imported true).
d. Into approved needs every approval approved with a signature_id.
e. Into implemented needs approved, and checks every approval again.
f. Unique (eco_id, role) and (eco_id, approver_id) on plm_eco_approval.
g. An ECO may be inserted already implemented only with ext imported true.
And plm_check_effectivity(eco_id), called by (e): refuses an effective date on or before the start of the revision being replaced, a second revision of the part starting the same day, and date and serial effectivity mixed on one part.
2. config/ccb.json listing the three board functions: engineering, manufacturing, purchasing.
3. Three routes, listed in docs/matrix.json and lib/access/routes.ts:
- /api/plm/submit (eco-submit): one active ccb_member per function from config/ccb.json who is not the ECO's creator; inserts three pending approvals and moves the ECO to ccb_review; refuses with a message naming any function with no approver.
- /api/plm/sign (the signed-in member, no account of its own): asks for the password again; writes core_e_signature with meaning, printed name, signed_at from the server clock, auth_method password_reauth and record_hash = SHA-256 of the ECO number, title, type, effectivity, dispositions, impact, each affected item, each to-revision's description and the sha256 of its files, in a fixed order; updates the member's own row; locks the ECO row (select for update) before counting, so two members signing at once cannot both miss the last one; the member who completes the set moves the ECO to approved and writes plm.eco.approved; a rejection cancels the ECO with the comment.
- /api/plm/release (eco-release): recomputes the hash and refuses if any signature no longer matches; calls plm_check_effectivity; then in one transaction sets the old revision superseded, the new one released with released_by_eco_id, the part's current revision, the ECO implemented, and writes plm.part.released and plm.eco.implemented. Releasing twice is refused and writes no second event.
4. Tests for every refusal in 1 and 3, each shown failing once with its guard removed.
Push, open a pull request titled "PLM change flow", wait for the checks, and tell me the result.You will see recreated screen
- Checked again at the last step, even if the approvals were complete earlier.
- Read this sentence. It is the second promise of the module, proven.
Check it worked
The pull request is green; the summary names each refusal; signing uses the signed-in member's session and asks for the password again; you have applied it to the development project by the routine after Step 5.
If it goes wrong
Two board members sign at the same moment and the ECO stays in ccb_review
Both counted the other as pending. We hit the same kind of race elsewhere: two saves at once and one lost. Say: Lock the ECO row with select for update before counting the approvals, and add a test with two signatures started together.
The sign route uses the secret (service role) key
That key skips every access rule, so a member could sign another's row. Say: Sign as the signed-in member's own session; never use the secret key in this route.
The release half-happened: B is released but the ECO is still approved
Say: Do every release write in one transaction, and add a test that a failure in the last write leaves nothing changed.
Session 4: Walk ECR-0001 to revision B, and try to break it
35 minutesWhy
Running the whole change as the six seed people, in order, is the test that the matrix, the guards and the routes fit together, and that every role has exactly the rights it needs. Trying to break it on the way, with two of three signatures and with an approval reset, proves the promise rather than assuming it. Running it as a journey test means it is proven again on every future change.
Do this
On a new branch plm/journey, add a journey test, signing in the six seed people the way the Session 19 journeys sign in test users, that runs on a fresh database in CI:
1. Seed Buyer raises ECR-0001 "Clarify the bearing drawing note", reason "Course example", priority medium. Seed Design Engineer moves it to evaluating; Seed Board Engineering approves it with a comment.
2. Seed Design Engineer creates ECO-0001 "Bearing drawing note, revision B", change_type document, linked to ECR-0001; affected item PLM-5000 from A to a new revision B with a synthetic pdf; ECR to converted; ECO to impact_analysis.
3. Seed Design Engineer runs plm_where_used on PLM-5000 and stores in ext.impact the six part numbers, the count and "no parent revision needed".
4. Seed Manufacturing Engineer sets effectivity_type date, effective_at 2026-11-02, wip_disposition na, field_action none. Seed Buyer sets stock_disposition use_as_is. The buyer changing effective_at, and the manufacturing engineer changing stock_disposition, are both refused.
5. Revision B to in_review; /api/plm/submit opens the review with three pending approvals.
6. Two members sign. Then approve, implement and /api/plm/release are each refused. Seed Design Engineer editing revision A is refused. The third member signs; the ECO is approved.
7. Inside a rolled-back transaction, one approval reset to pending: implement is refused.
8. /api/plm/release: plm_resolve_revision gives A on 2026-11-01 and B on 2026-11-02; plm_bom_compare of PLM-1000 between those dates returns exactly two rows, the two PLM-5000 lines; plm.eco.approved, plm.part.released and plm.eco.implemented are each in the outbox exactly once; a second release is refused.
Point /plm/bom at plm_resolve_revision with its date box. Print a short summary of each check. Push, open a pull request titled "PLM change journey", wait for the checks, and tell me the result.When it is green, apply the new migrations to the development project yourself, as in Step 5, and open /plm/changes on the preview.
cd ~/code/acme-platform && git switch plm/journey && git pull && npx supabase link --project-ref tsrqponmlkjihgfedcba && npx supabase db pushYou will see recreated screen
- Every refusal the module promises, shown as it happens.
- The numbers you can check by hand: two dates, two rows, three events.
You will see recreated screen
| Role | Approver | Decision | Signed |
|---|---|---|---|
| engineering | Seed Board Engineering | approved | 2026-11-12 10:02 |
| manufacturing | Seed Board Manufacturing | approved | 2026-11-12 10:05 |
| purchasing | Seed Board Purchasing | approved | 2026-11-12 10:07 |
- Implemented only after all three signatures.
- Each signature shows the printed name and the time from the server clock.
Check it worked
The journey is green and its summary shows every refusal, A on 2026-11-01 and B on 2026-11-02, two compare rows and three events once each. Owner two approves and it merges; the pipeline applies the migrations to production.
Fastest path
One journey test replaces an afternoon of clicking through six sign-ins by hand, and it runs again on every pull request from now on.
If it goes wrong
The journey stops: the buyer cannot insert the ECR
A right is missing from the matrix. Check docs/rights-walk.md has the line, then say: Add the missing cell to docs/matrix.json, regenerate the rules, and rerun the journey. Never grant it in a hand-written policy.
The summary says passed but the check on GitHub is red
Say: Show me the exact command, its exit code and the last 20 lines of its output. We recorded a run that printed npm: not found and, minutes later, reported 1,326 tests passing.
The check is red on something this pull request did not touch
It may have run on an old commit. Say: Tell me which commit the check ran on. If it is behind main, merge origin/main, push, and wait for the new checks.
Knowledge check
An ECO has two of three approvals signed. What happens when someone tries to implement it?
Knowledge check
Why does the module store only the date each revision starts?
References
- Supabase Docs: Row Level Security. https://supabase.com/docs/guides/database/postgres/row-level-security
- PostgreSQL Documentation: WITH queries (recursive). https://www.postgresql.org/docs/current/queries-with.html
- eCFR: 21 CFR Part 11, Electronic Records; Electronic Signatures. https://www.ecfr.gov/current/title-21/chapter-I/subchapter-A/part-11
- Guideflow: engineering change management software. https://www.guideflow.com/blog/engineering-change-management-software
- PostgreSQL Documentation: Explicit locking (SELECT FOR UPDATE). https://www.postgresql.org/docs/current/explicit-locking.html
Chapter 3 · Sessions 5 and 6
Move the real data, cut over and switch the old tool off
Session 5 builds the loader and the checks and rehearses them on the development project with a copy IT has approved. Session 6 imports the real records into production through the import workflow, started by a person from main with an export owner two approved, checks the counts match, runs both tools side by side, cuts over, closes the loader and cancels the old subscription with the saving written down.
30 minSteps 11–13About 2 hours 15 minutes hands-on in these two sessions, plus a side-by-side week
By the end of this chapter you can
- Build an import that is a dry run by default, adds nothing on a second run, and reports every row it cannot place.
- Rehearse on the development project with an IT-approved copy, then import into production through import-plm.yml from main with an approved export, never from a laptop.
- Check that counts match and that every assembly and every date resolves exactly one revision.
- Cut over, close the loader, and cancel the old tool with the saving taken from invoices.
What comes across, and in what order
Only the current released revision of each part, its BOMs, the approved manufacturers, the declarations and the files come across. Past changes come in as closed ECOs only where an auditor or a customer requires them; everything else stays in the old tool's final export, kept in company storage. The loader writes in this order, because each step needs the one before it:
- Units, manufacturers and items (an item another module already made is reused, never copied).
- Parts, then each part's current revision in_work with ext baseline true.
- Files, before the release, because a released revision is frozen.
- The release of each revision; then BOMs in_work with their lines, released only when every child resolves.
- Approved manufacturers and declarations, only where the old tool holds them.
- Closed ECOs (eco_no LEG- and the old number), implemented, with ext imported true, only where required.
| Check before cut-over (zero exceptions) | Why |
|---|---|
| Every released or deprecated part points at a released revision of itself; concept, in_design and prototype parts have none | A part that says released must have something released to build |
| No released BOM has a child without a released revision | Every assembly resolves to released components |
| Exactly one revision resolves for every released part on 2000-01-01, today and 2030-01-01, and on every ECO's effective date and the day before | MES and MRP always get one answer |
| No part is its own ancestor | Where-used and explosions always finish |
| Counts of parts, revisions, lines, manufacturer parts, declarations and files match the export, every skipped row explained | Nothing lost silently |
Session 5: The loader and the checks, rehearsed on the development project
45 minutesWhy
An import is the one time a large amount of data enters at once, so it must be repeatable, honest about what it could not place, and impossible to run from a laptop by accident. A dry run first, a second run that adds nothing, and a deliberately broken row that the loader must hold back prove that before any real record moves. Rehearsing on the development project with a copy IT approved finds the mapping errors where they cost nothing.
Do this
Real records are company data. Before they go anywhere but the old tool, get IT's written yes:
To: IT
Subject: Rehearsing the PLM import on our development project
We are replacing <old tool> with the product lifecycle module on the Acme Bottling platform. Before importing into production, we want to rehearse once on our development Supabase project (acme-platform-dev) with a copy of the export: parts, current revisions, bills of materials, approved manufacturers, declarations and file fingerprints. No CAD files.
Personal data (people's names and emails in the change history) would be redacted first. The copy would be uploaded by me to a private storage bucket in that project, used for one rehearsal, and removed from the project the same day, with the date recorded in docs/imports/plm-approved.md.
Please reply "approved", or tell us what to change.Read docs/plm-map.md, the M14 section of docs/spine-map.md, docs/matrix.json and the deploy workflow from Session 11.
On a new branch plm/import:
1. docs/import-map.md: old part to core_item and plm_part; old revision to plm_part_revision; old BOM to plm_bom and plm_bom_line; every old lifecycle state to one of the six (a row "to settle" for any I have not decided); every old unit to core_uom; make, buy or phantom.
2. scripts/import-plm.mjs, running as the plm_loader database role, which is insert-only (no update, no delete; created NOLOGIN by a migration, its login turned on by a person with a password they set and name in docs/KEYS.md): a dry run by default that writes nothing; --apply to write; the order: units, manufacturers, items, parts, current revisions in_work with ext baseline true, files (core_attachment with the real sha256, classification confidential, and plm_file), BOMs in_work with their lines, then one call to plm_import_release(batch), a security definer function in the same migration and the only thing the loader may execute, which releases the batch's baseline revisions and each BOM whose children all resolve, touching only rows with ext imported true and that batch id, manufacturer parts, declarations, closed ECOs with ext imported true. It finds existing items by item_no and manufacturers by name, so a second run adds nothing. It reports every row it cannot place, with the reason, and never releases a BOM with a missing line. Revision ids come from crypto.randomUUID() so a part can name its current revision on insert.
3. scripts/check-plm.mjs, running as plm_check (read only): the counts against the export, and the zero-exception checks: current revisions, released BOM children, exactly one revision on 2000-01-01, today, 2030-01-01 and every ECO's effective date and the day before, no loops; plus compliance coverage on today's date. Counts and part numbers of exceptions only: never descriptions or file contents in the output.
4. .github/workflows/import-plm.yml, run by hand only (workflow_dispatch) from main, refusing any other branch, with inputs target (development or production) and mode (dry-run or apply). It fetches the export from the private Storage bucket imports in the target project; refuses it unless every file's sha256 and expected counts are listed in docs/imports/plm-approved.md on main; runs the loader in one transaction, then the checks; fails, keeping nothing, on any count that differs from the approved file; and writes the check report to the job summary. It signs in as plm_loader with that target's password secret (PLM_LOADER_PASSWORD_DEV or PLM_LOADER_PASSWORD), which I add; tell me if it needs any other secret. No GitHub environment with required reviewers (the Team plan does not offer them for private repositories): the reviewed pull request that merges the approved file is the approval.
5. Tests with a small synthetic export: dry run writes nothing; apply then apply again adds nothing; a line whose child is not in the export is reported and its BOM stays in_work; a file whose sha256 is not approved is refused; a count mismatch fails and keeps nothing; plm_loader cannot update or delete.
Push, open a pull request titled "PLM loader", wait for the checks, and tell me the result.When IT has approved and the pull request has merged: in the development project's SQL editor turn on plm_loader's login with a password you make (alter role plm_loader login password '…'), keep it in the password manager, add it as the Actions secret PLM_LOADER_PASSWORD_DEV and name it in docs/KEYS.md. Upload the redacted copy to the bucket imports in the development project and record its fingerprints.
https://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/storage/buckets
Create a private bucket named imports (Public off) and upload the export copy.
shasum -a 256 *On a new branch plm/import-approval, write docs/imports/plm-approved.md with a section "Rehearsal (development project only)": each file's name, sha256 and expected counts (parts, revisions, BOM lines, manufacturer parts, declarations, files, from the old tool's own reports in docs/plm-map.md), the date taken, what was redacted, and IT's written approval (date and role). Open a pull request titled "PLM: approve rehearsal export".
<paste the shasum lines and the counts>Owner two reviews and approves; merge. Then run the workflow on the development project as a dry run, then apply, then apply again.
https://github.com/acme-ops/acme-platform/actions/workflows/import-plm.yml
Run workflow: target development, mode dry-run. Read the summary. Then apply, then apply once more.
You will see recreated screen
| Check | Exceptions |
|---|---|
| Current revision is released | 0 |
| Released BOM children released | 0 |
| Exactly one revision on every date | 0 |
| No loops | 0 |
- Matches the counts from the old tool's own reports in docs/plm-map.md, or every difference is listed.
- Held back is correct: a real finding for the design engineer, not a check to loosen.
- Zero, on every check, before anything goes to production.
Check it worked
The dry run wrote nothing; apply matched docs/imports/plm-approved.md with every skipped row explained; the second apply added nothing; the four checks show zero. Then remove the copy from the development project the same day (its imported rows and the file in the bucket) and record the date in docs/imports/plm-approved.md.
If it goes wrong
The workflow refuses: sha256 not approved
The file changed since you recorded it (often opened and saved in a spreadsheet, which rewrites it). Upload the approved file again, or record the new fingerprint through a pull request owner two approves.
The workflow fails with Invalid URL, or the address is refused
We hit this: a database address pasted with quotes, a NAME= prefix, a space or an unencoded character in the password. Re-enter the secret with the value only. Say: Report which problem the address has without printing it.
A BOM with a missing child was released anyway
The release gate only sees lines that were inserted; the missing line was never inserted, so the rest resolved. Say: The loader must hold back any BOM with an unplaced line, and the synthetic test must prove it.
The second apply added rows
Say: The loader is not idempotent. Find each table where a second run inserts, match existing rows by their natural key, and add the test.
IT has not answered
Wait. Rehearse with the synthetic export only. Real records do not move without the written yes.
Knowledge check
The loader cannot find a BOM line's child part in the export. What should happen?
Measures and what the old tool cost
| Measure | Definition |
|---|---|
| ECO cycle time | Median days from the ECR opening to the ECO being implemented |
| Changes per released part | ECOs divided by released parts, for a period |
| Compliance coverage | Bought parts with a current declaration (compliant or exempt, valid_until empty or not past) divided by bought parts |
| BOM accuracy at release | Post-release BOM corrections divided by releases (needs a record of corrections, added later) |
Session 6: Import into production through the pipeline, and check the counts
30 minutesWhy
Production changes only through reviewed code run by the pipeline, never from a laptop: a deploy from a laptop once sent local settings to our production and broke three pages. Running the same workflow that passed the rehearsal, started by you from main, on an export whose fingerprints and counts owner two approved in a reviewed pull request, means the import that reaches production is exactly the one you already checked, and the counts prove nothing was lost.
Do this
Take the final export. Upload it to a private bucket imports in the production project. Turn on plm_loader's login in production with a new password you make, keep it in the password manager, add it as the Actions secret PLM_LOADER_PASSWORD and name it in docs/KEYS.md.
https://supabase.com/dashboard/project/abcdefghijklmnopqrst/storage/buckets
Production project storage: a private bucket imports, Public off. Upload the export.
On a new branch plm/import-production, add a section "Production" to docs/imports/plm-approved.md: each file's name, sha256 and expected counts, and the date taken. Open a pull request titled "PLM: approve production export".
<paste the shasum lines and the counts>Owner two reviews and approves; merge. Then run the workflow, first as a dry run.
https://github.com/acme-ops/acme-platform/actions/workflows/import-plm.yml
Run workflow from main: target production, mode dry-run. Compare with the rehearsal and the approved file. Then mode apply.
Then record the result:
The production import has run (run <paste the run link>). From its job summary, write docs/import-report.md on a new branch plm/import-report: the date, who ran it and who watched, the counts against the export, every skipped or held-back row with its reason, the four zero-exception checks, the compliance coverage on today's date, and the date the development copy was removed (from docs/imports/plm-approved.md). No part descriptions or file contents. Open a pull request titled "PLM import report".You will see recreated screen
- Always main: the code that ran in the rehearsal, reviewed and merged.
- Owner two approved these fingerprints and counts in a reviewed pull request; any other file is refused.
You will see recreated screen
| Check | Exceptions |
|---|---|
| Current revision is released | 0 |
| Released BOM children released | 0 |
| Exactly one revision on every date | 0 |
| No loops | 0 |
- The same explained differences as the rehearsal, and no new ones.
Check it worked
Production's counts match docs/imports/plm-approved.md with the same explained skips as the rehearsal, the four checks are at zero, and docs/import-report.md is merged.
If it goes wrong
The run fails: a count differs from the approved file
Nothing was kept: the import runs in one transaction. Find why (a re-export, a filter in the old tool) and approve the right file through a new pull request. Never edit the counts to fit.
Someone suggests a GitHub environment with required reviewers
Not available on the Team plan for private repositories. The reviewed pull request that merges docs/imports/plm-approved.md is the approval.
A count differs from the rehearsal
Stop before cut-over. Say: Compare the production and rehearsal summaries and list every count that differs, with the rows behind it. A difference you cannot explain means you are not ready.
Someone suggests running the loader from a laptop to save time
Do not. Production comes only from main through the pipeline. A laptop run uses whatever is on that laptop.
A check fails that worked in the rehearsal
Read which part and date it names, then fix the mapping with the design engineer. Never loosen the check.
Session 6: Side by side, the three promises, cut over, and cancel
60 minutes, after a side-by-side weekWhy
A week in which every real change is raised in both tools shows whether the module holds the same product data and the same changes, before anyone depends on it alone. Checking the module's three promises on production data, closing the loader so nothing can bulk-write again, and cancelling the old tool only after the final export is stored turns the saving into a fact with a date.
Do this
For one week, every real change for the pilot family is raised in both tools by the same people. Then:
On a new branch plm/cutover, write docs/cutover.md:
1. The side-by-side week: each day's ECR and ECO counts by status in both tools (I will paste the old tool's), and an explanation for every difference.
2. Ten explosions from the pilot family with plm_explode for today (part number, level, quantity, unit, revision), and the where-used of five parts, against the old tool's reports I paste; every difference and its cause.
3. The three promises, each with the test or query that proves it on production data: a released revision and its BOM cannot be edited (rolled-back attempts); an ECO cannot be implemented without every signature (the journey from Session 4); exactly one revision resolves (scripts/check-plm.mjs, including every ECO's effective date and the day before).
4. The measures from scripts/check-plm.mjs: ECO cycle time beside the Session 1 baseline, with how many changes are behind each (with few, say so and claim nothing); changes per released part; compliance coverage on the cut-over date.
5. The cut-over date, changes in flight and who finishes each, who keeps the final export and where, and the date after which a change recorded only in the old tool is not valid.
Then close the loader: remove plm_loader from docs/matrix.json, regenerate the access rules, add a migration that sets the plm_loader role to NOLOGIN (I delete its password secrets and note the date in docs/KEYS.md), mark its lines in docs/rights-walk.md retired with the date, and add a test that an import is now refused.
My figures:
<paste the old tool's counts and reports>
Push, open a pull request titled "PLM cut-over", wait for the checks and tell me the result.On the cut-over date: take the old tool's final export (all revisions, BOMs, change history with attachments, files), store it in company storage, and check the file count and the sha256 of five files against the old vault. Then set the old tool read-only. Read the cancellation terms on your own account page, cancel (keeping any CAD seats that are separate), and record it:
Add to docs/plm-map.md on a new branch plm/retired: each tool and spreadsheet marked replaced or retired with the date; the cancellation (date, notice period, the last invoice amount as I give it); and the saving as arithmetic: the old yearly cost from the invoice, minus what the module adds to services we already pay for, from our own bills. My figures: <paste from the invoices>. Open a pull request titled "PLM tool retired".You will see recreated screen
- Honest numbers. Four changes are not enough to claim the module is faster; say so.
- After cut-over nothing can bulk-write product data again.
Check it worked
docs/cutover.md is merged with every difference explained and the three promises proven; the loader is refused; the final export is stored and checked; the old tool is read-only or cancelled, with the saving written as arithmetic from invoices in docs/plm-map.md.
If it goes wrong
A change exists in only one tool
That is a finding, not noise. Find who raised it and why it skipped the other tool, and fix the habit before cut-over.
The rights-walk test fails once the loader is removed
Its lines must be marked retired, not deleted. Say: Mark every plm_loader line retired with today's date; the test skips retired lines.
The vendor's notice period has passed for this year
Write the date the plan ends and set a reminder for the next notice date. Keep the old tool read-only until then; do not let anyone go back to it.
Knowledge check
After cut-over, why is the plm_loader role removed from the matrix and set to nologin?
References
- GitHub Docs: Events that trigger workflows (workflow_dispatch). https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch
- GitHub Docs: Using secrets in GitHub Actions. https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions
- EUR-Lex: Directive 2011/65/EU (RoHS). https://eur-lex.europa.eu/eli/dir/2011/65/oj
- EUR-Lex: Regulation (EC) No 1907/2006 (REACH). https://eur-lex.europa.eu/eli/reg/2006/1907/oj
- Supabase Docs: Storage. https://supabase.com/docs/guides/storage
Chapter 4 · 12 questions · 80% passes
Final assessment
Twelve questions across the element. Score 80% (10 of 12) to pass. Your LMS records your score and each answer; you can review the chapters and try again.
15 min12 questions≈ 15 minutesRetake allowed
Your result
CivOps AI Academy
Product Lifecycle (PLM): Parts, Bills of Materials and Engineering Change as Controlled Records
Element M14 complete · Learner
Your LMS records this completion. For the CivOps Foundation certificate, finish the Foundation Course at https://civops.io/learn.