Twenty-one migrations. Every one of them solved a real problem.
Four phases since the project began: foundation, price intelligence, auditability, refinement. Each entry shipped because somebody on the team got tired of the workaround.
Foundation
Drawings, jobs, KSS skeleton, file-hash dedupe, nullable joins so partial drawings can still be priced.
Price intelligence
Scrape pipeline v2, line-item price columns, DRM rules, KSS reports table.
Auditability
AI dual-mode KSS, audit trail, suggestions, ERP foundation, draft status.
Refinement
Pricing defaults + EUR, phase-4 audit duals, quantity norms, scraper runtime, extraction traceability, the explicit totals ladder.
- 001
Initial schema
drawings, jobs, kss_line_items, kss_corrections.
- 002
File hash dedupe
SHA-256 on every upload. Same file twice is one row.
- 003
KSS bootstrap
Bulgarian СЕК group taxonomy, ОБРАЗЕЦ 9.1 column shape.
- 004
Scrape prices
First version of scraped_price_rows for supplier pricing.
- 005
Nullable job → drawing
Allow KSS jobs that operate on partial parses.
- 006
Scrape pipeline v2
Worker schedules, partial results, BrightData proxy contract.
- 007
Price LV columns
Labour, material, mechanisation, overhead split persisted, not computed.
- 008
DRM (Drawing Rule Mapping)
Per-user rules to override layer→СЕК group decisions.
- 009
Price CRUD
Editable prices in the UI, with audit on every change.
- 010
KSS reports
Versioned KSS snapshots; old versions remain queryable.
- 011
AI KSS dual-mode
Standard pipeline + AI pipeline (research → review → generate).
- 012
KSS audit trail
kss_audit_trail records every fired rule, source, and Opus reasoning.
- 013
Suggestions
Low-confidence rows surface to a review widget instead of rolling silently.
- 014
ERP foundation
erp-core types: money, units, codes. Used by future BOQ + costs work.
- 015
KSS draft status
Drafts vs finalized — only finalized exports go out.
- 016
Pricing defaults + EUR
Per-org defaults, EUR support, anchor bands per СЕК.
- 017
Phase-4 audit dual code
Dual-coding of audit entries against a versioned schema.
- 018
Quantity norms
Per-unit consumption norms (e.g. m³ concrete per m² wall).
- 019
Quantity scraper runtime
Norms can be researched live when missing.
- 020
Extraction traceability
Every quantity carries an extraction_method and confidence.
- 021
Explicit totals ladder
Subtotals at every aggregation level. No more "where did this number come from".