Schema Changelog
Complete version history for schema.sql. All changes are additive (no breaking alterations). File targets Cloudflare D1 / SQLite 3.37+.
After V11, the schema moved to numbered incremental migrations under db/migrations/ (0001_initial.sql … 0019_pension_depth.sql); schema.sql and db/migrations/schema_d1.sql carry the equivalent full snapshot. Current total: 418 tables.
Migration era (0002–0019) — 276 → 418 tables
Theme: From a regulatory-reporting reference to a full-scope, traceable operating model — every figure now computes bottom-up and reconciles via npm run check:trace.
| Migration | Tables | Net Δ | Adds |
|---|---|---|---|
0002 | 276 | +1 | recon_break — GL↔subledger↔nostro reconciliation breaks (BCBS 239 P8; DORA Art. 11) |
0003 | 281 | +5 | Climate-risk integration: esg_portfolio_metric + climate reference-cache columns (ECB Guide; TCFD; CSRD) |
0004 | 281 | +0/refit | Paperclip agent operations: app_user_role, agent_proposal (HITL spine), agent_eval, agent_change_request |
0005 | 298 | +17 | FINREP/COREP reporting layer — EBA DPM metamodel + rpt_datapoint_value + 10 v_* views (ITS 2021/451) |
0006 | 311 | +13 | DPM versioning backbone, XBRL projection, conformed mart star, audit_log hash-chain immutability |
0007 | 311 | +0 | GL → FINREP F 01.01 wiring (balance-sheet integrity link) — views only |
0008 | 312 | +1 | IFRS 9 ECL engine: ecl_allowance_movement + per-exposure staging/allowance → FINREP F18 |
0009 | 312 | +0 | Bottom-up capital chain (SA + IRB + market + op → TREA → CET1) + 6-quarter history + P&L from ledger — views only |
0010 | 328 | +16 | Product capabilities (on-balance): cards + instant lombard, alternatives, OTC derivatives + structured products (SA-CCR + CVA → TREA), tokenized-RWA (TVTG) |
0011 | 355 | +27 | Product capabilities (off-balance): crypto custody + staking (MiCA), fiduciary/trust, insurance wrappers, payments modernisation, AI-advisory, fee_attribution |
0012 | 369 | +14 | Asset management: ManCo/AIFM, managed funds, share classes + NAV, investor register, AIFMD Annex IV, depositary oversight, segregated mandates; bank seed → GL 1330 (CET1 13.84%) |
0013 | 379 | +10 | Pension (LI/CH 2nd & 3rd pillar): foundations, plans, members, 1e, vested benefits, annuities, actuarial valuation |
0014 | 387 | +8 | Investment research / CIO office: house view, asset allocation, IC decisions, conviction theses |
0015 | 394 | +7 | Fund economics: income/expense accrual with computed TER (replaces flat 75bps), fund P&L, liquidity ladder, AIFMD Art.16 LST, LMT toolkit (swing/dilution/gates) |
0016 | 400 | +6 | ManCo prudential: AIFMD Art.9 own-funds adequacy, programme of activity, PII cover, fund prospectus, AIFMD Annex IV risk/exposure detail |
0017 | 405 | +5 | Management steering (MIS): business segments, segment P&L (ties to GL net profit), RAROC vs TREA economic capital, operating plan, plan-vs-actual variance |
0018 | 413 | +8 | Conduct & servicing: MiFID II research payment account + budget, restricted list + wall-crossing, ManCo delegate oversight, fund best-execution, TA late-trading controls |
0019 | 418 | +5 | Pension depth: 1e investment-choice governance, OAK-BV/FMA supervisory reporting, Sanierung remediation, conversion-rate assumptions |
Net effect across 0010–0014: AUM 763 m → 1.213 bn, four new ADS-v2 agents (roster → 32), TREA → 317.84 m / CET1 13.84 %.
V10 — 275 tables (+10 from V9)
Theme: Second-cycle SREP examination readiness; loan origination, collateral monitoring, personal dealing controls.
| Table | Regulation | Key Design |
|---|---|---|
loan_creditworthiness_assessment | EBA GL/2020/06 §5.2–5.4; CRR Art. 79 | Income/expense verification, LTV; VIRTUAL DSCR and stressed DSCR; interest rate stress test; override workflow |
collateral_valuation_record | CRR Art. 208(3); EBA GL/2020/06 §7 | Revaluation history; VIRTUAL current LTV and post-haircut value; CRR overdue flag; market-decline trigger; MLV for real estate |
personal_account_dealing | MiFID II Art. 29; Del. Reg. 2017/565 Art. 9–11; MAR Art. 14 | Pre-clearance workflow; restricted list check; VIRTUAL holding-period breach flag; insider dealing confirmation |
outsourcing_arrangement | EBA GL/2019/02; CRD Art. 65; BankG Art. 9a | Non-ICT outsourcing register; criticality classification; FMA notification; exit plan; concentration risk; audit rights |
gift_entertainment_record | MiFID II Art. 27(4); Del. Reg. 2017/565 Art. 6 | Minor non-monetary benefit threshold; VIRTUAL rolling 12-month cumulative; pre-approval; conflict flag |
ilaap_liquidity_stress_result | EBA GL/2014/04 §4.2–4.4; CRD Art. 86 | Survival horizon before/after management actions; post-stress LCR; VIRTUAL FMA minimum-survival threshold breach |
mica_nca_quarterly_report | MiCA Art. 22 (ART) + Art. 45 (EMT) | Token circulation + reserve assets; VIRTUAL backing ratio; significance threshold; dual FMA + ESMA submission |
fma_dora_incident_report | DORA Art. 19–20; Del. Reg. 2024/1772 | Three-stage cadence (4h / 72h / 1 month); VIRTUAL on-time flags; cross-border NCA notification; FMA reference |
complaint_fma_aggregate_report | MiFID II Art. 26(2); EBA/ESMA GL/2014/07 | Annual/semi-annual aggregate; SLA % metrics; systemic issue flag; ADR escalation; total redress |
irrbb_nii_projection | EBA GL/2022/14 §5.2; CRR Art. 84(6); BCBS 368 | 6-scenario NII projection; VIRTUAL Δ CHF / Δ % baseline / Δ % total assets; NII SOT breach flag |
V9 — 265 tables (+28 from V8)
Theme: Credit lifecycle, client protections, hedge accounting, ICAAP/ILAAP formalisation.
| Table | Regulation | Key Design |
|---|---|---|
loan_facility | BankG Art. 9; CRR Art. 147; EBA GL/2017/06 | Facility lifecycle; VIRTUAL drawn amount and undrawn; CRR exposure class; IFRS 9 stage; default flag |
loan_drawdown | BankG; CRR Art. 166; IFRS 9.4.1.2 | Drawdown against facility; VIRTUAL net carrying amount; EIR; ECL allowance |
loan_repayment_schedule | BankG; CRR Art. 178; IFRS 9 | Instalment schedule; VIRTUAL arrears and DPD; SICR trigger |
standing_settlement_instruction | MiFID II Art. 16(6); CSDR Art. 5 | Per-counterparty/currency/location SSI; DvP flag |
professional_client_waiver | MiFID II Annex II §I.2 | Opt-up/opt-down; VIRTUAL 2-of-3 criteria check; written warning; acknowledgement |
client_asset_segregation_check | MiFID II Art. 16(9); Del. Reg. 2017/565 Art. 68–73 | Daily reconciliation; break count; FMA reportable breach flag |
sfdr_periodic_report | SFDR Art. 11; RTS 2022/1288 Annex IV | Annual sustainability product report for Art. 8/9 products |
hedge_accounting_relationship | IFRS 9.6.1–6.4 | Formal designation; hedging instrument; hedged item; hedge ratio justification |
hedge_effectiveness_test | IFRS 9.6.4.1 | Dollar-offset / regression / hypothetical derivative; VIRTUAL ratio; OCI movement |
retrocession_payment | MiFID II Art. 24(7)–(9); Del. Reg. 2017/565 Art. 11–12 | Inducement register; direction; quality-enhancement test; client disclosure |
icaap_submission_log | EBA GL/2018/04 §5.1; CRD Art. 73 | Board approval; FMA submission; VIRTUAL capital surplus/deficit; SREP P2R linkage |
reverse_stress_test | EBA GL/2018/04 §6.5; BCBS Stress Testing Principles §13 | 3 failure scenarios; credit/market/deposit thresholds; management action survival flag |
loan_covenant | BankG; CRR Art. 178; EBA GL/2017/06 §2.3 | Type (financial/affirmative/negative/reporting); numeric threshold; test frequency |
loan_covenant_breach | CRR Art. 178; IFRS 9 Stage 2 | Severity; UTP trigger; stage-change flag; cure/waiver/default lifecycle |
economic_capital_allocation | EBA GL/2018/04 §5.2–5.3 | Pillar 1 RWA; nine Pillar 2 add-ons; VIRTUAL total internal capital; VIRTUAL surplus/deficit |
nsfr_asf_item | CRR Art. 428c–428i; COREP C80.00 | 15 ASF categories; VIRTUAL weighted ASF |
nsfr_rsf_item | CRR Art. 428k–428ax; COREP C80.00 | 20 RSF categories; encumbrance remaining tenor; VIRTUAL weighted RSF |
corporate_action_election | MiFID II Art. 24; CSDR | Elected option; deadline; custodian instruction; late submission flag |
aml_training_record | SPG Art. 21; FATF R.18; EBA/GL/2021/02 | Per-staff training; VIRTUAL assessment passed; SPG Art. 21 satisfied flag |
ifrs9_interest_accrual | IFRS 9.4.1.2 | EIR accrual; VIRTUAL accrued interest; Stage 3 net adjustment; GL linkage |
succession_plan | CRD Art. 88; EBA GL Gov 2021 §4.3 | Immediate + medium-term pipeline; key-person risk rating; single-point-of-failure flag |
fatca_crs_threshold_monitor | FATCA IGA Annex I; OECD CRS Sect. II–III | USD 50k/1M/250k thresholds; VIRTUAL high-value classification; RM review trigger |
account_statement_log | MiFID II Art. 25(6); Del. Reg. Art. 59–62 | Statement issuance; delivery confirmation; portal client-viewed timestamp |
corep_finrep_bridge | EBA ITS 2021/451 + 2021/453 | Regulatory filter line items; VIRTUAL unexplained difference; reconciled flag |
dpo_activity_log | GDPR Art. 38–39; DSG FL | DPO consultation; independence issue flag; follow-up tracking |
ubo_threshold_event | SPG Art. 35a; PGR Art. 107a; 5AMLD | Ownership crossing events; VIRTUAL notification lag; PPR filing deadline |
sla_fee_accrual | SFTR; IFRS 9; ISLA GMSLA | Securities lending fee accrual; VIRTUAL amount (principal × bps × days/365); GL linkage |
vat_record | FL MWSTG; EU VAT Dir. Art. 135 | Exempt/taxable split; VIRTUAL net VAT position; FL MWSTG filing reference |
V8 — 237 tables (+36 from V7)
Theme: GDPR Records of Processing, AML case management, LCR full decomposition, GAR/BTAR, DGS, related parties, operational infrastructure.
New tables: ropa_record, ropa_processor_record, aml_investigation_case, sanctions_freeze_action, fiu_feedback, ccyb_rate_register, capital_buffer_calculation, lcr_hqla_item, lcr_outflow_item, lcr_inflow_item, gar_calculation, btar_calculation, conflict_of_interest, best_execution_policy, dgs_eligible_deposit, dgs_contribution_calc, related_party, related_party_transaction, contingency_funding_source, capital_plan_projection, margin_call_event, tax_report_amendment, client_portal_access_log, annual_financial_statement, capital_ratio_daily, governance_meeting_minutes, derisking_decision, power_of_attorney, conduct_attestation, swift_message_log, ftp_rate, ftp_allocation, alm_repricing_gap, bcp_test_record
Scaffold: supervisory_stress_test_submission, gips_composite
V7 — 201 tables (+23 from V6)
Theme: BCBS 239 13/13 completion; COREP operational; IFD/IFR; DORA threat intelligence.
New tables: securitisation_position, securitisation_due_diligence, sts_notification, ifd_classification, ifd_k_factor_calc, intraday_liquidity_monitor, corep_credit_risk_submission, corep_operational_risk_submission, client_complaint, approved_person_register, model_risk_register, new_product_approval, concentration_risk_limit, concentration_risk_usage, staff_competence_record, mrel_reporting_submission, dora_threat_intelligence, onboarding_workflow, risk_report_distribution, country_by_country_report
Scaffold: anacredit_counterparty_report, anacredit_instrument_report, anacredit_protection
V6 — 178 tables (+10 from V5)
Theme: IRB rating models, GIPS performance, collateral eligibility, FINREP, IPS, GMSLA.
New tables: irb_rating_model, irb_rating_assignment, performance_record, performance_attribution, tax_reclaim_record, collateral_eligibility_rule, pre_trade_waiver, finrep_template, investment_policy_statement, securities_lending_agreement
V5 — 168 tables (+9 from V4)
Theme: Remuneration/MRT, benchmark/BMR fallback, derivatives lifecycle, ICAAP stress, IFRS 13 fair value.
New tables: remuneration_identified_staff, remuneration_award, remuneration_clawback, benchmark_usage_record, benchmark_fallback_plan, derivative_lifecycle_event, icaap_stress_scenario, icaap_stress_result, fair_value_measurement
V4 — 159 tables (+14 from V3)
Theme: SA-CCR/CVA capital infrastructure, own funds registry, SRD II, PSD2/SCA.
New tables: isda_master_agreement, netting_set, sa_ccr_netting_set_calc, sa_ccr_hedging_set, cva_risk_charge, asset_encumbrance_item, asset_encumbrance_report, own_funds_instrument, own_funds_deduction, adverse_media_record, proxy_voting_policy, proxy_voting_record, sca_event, tpp_consent
V3 — 145 tables (+58 from V2)
Theme: 2024–2026 regulatory gap closure across EEA/Liechtenstein.
Sections K–AA (new sections added after V2 sections A–J):
| Section | Tables Added | Regulation |
|---|---|---|
| K | 5 | SFDR (PAI indicators, taxonomy) + EU Taxonomy screening criteria |
| L | 4 | MiCA (ART/EMT classification, whitepaper, reserve assets, CASP auth) |
| M | 1 | Travel Rule / TFR 2023/1113 |
| N | 1 | EMIR Refit collateral report + ALTER TABLE extensions (UPI, UTI namespace, ISO 20022) |
| O | 2 | PRIIPs (KID version, performance scenarios) |
| P | 3 | BRRD (recovery indicators, MREL liabilities, resolution actions) |
| Q | 3 | IRRBB (EVE/NII scenarios, behavioural assumptions, SOT) |
| R | 4 | FRTB/CRR3 (book boundary, SA sensitivities, PLA test, DRC) |
| S | 3 | Capital adequacy: output floor, NSFR calculation, Pillar 3 disclosure |
| T | 3 | Sanctions enhanced: list versioning, list entries, PPR UBO filing |
| U | 4 | MAR/MiFID II conduct: market soundings, communication taping, sustainability suitability |
| V | 2 | GDPR DPIA; Whistleblower (Dir. 2019/1937 + FL Hinweisgeberschutzgesetz 2023) |
| W | 1 | SFTR repo/SBL/margin lending trade reports |
| X | 2 | Climate risk (NGFS scenarios, physical/transition scoring) |
| Y | 3 | DORA Register of Information (RT-01→RT-05 contractual arrangements) |
| Z | 11 | Operational depth: CSDR penalties/buy-in, large exposures, leverage ratio, SMA losses, ICT vulnerabilities, MiFID II cost disclosure, PEP EDD, correspondent EDD, SREP outcome |
| AA | 6 | Scaffold: CSRD (ESRS), EU AI Act, AMLA 2027, Digital Euro, crypto prudential |
V2 — 87 tables (+67 from V1)
Theme: BIAN service domain alignment, BCBS 239 data quality, DORA ICT resilience, GL.
Sections A–J:
| Section | Domain |
|---|---|
| A | BIAN Core (nostro, product, fee billing) |
| B | General Ledger (COA, journals, trial balance) |
| C | DORA ICT (assets, incidents, third-party, change, TLPT) |
| D | MiFID II / MAR (EMIR, MAR surveillance, RTS28) |
| E | Risk Management (RCSA, KRI, credit committee, liquidity position) |
| F | BCBS 239 (data quality, lineage — 13/13 principles foundation) |
| G | Tax reporting (FATCA/CRS account reports) |
| H | Compliance calendar |
| I | Reference data (ref_country, ref_currency, ref_asset_class, reference_rate) |
| J | GL integration extensions |
V1 — ~20 tables
Foundation layer: legal_entity, branch, client, ubo, pep_record, sanctions_screen, document, kyc_review, account, account_balance, authorized_signatory, suitability_assessment, mandate, instrument, order_, trade, settlement, aml_alert, str, audit_log
Design Constraints (all versions)
- No breaking changes. Every version is additive: new tables, new indexes, new columns via
ALTER TABLE ADD COLUMN. Existing DDL never modified. - SQLite VIRTUAL columns only. No
STOREDgenerated columns — Cloudflare D1 (SQLite 3.37) does not supportSTORED. All computed columns useGENERATED ALWAYS AS (...) VIRTUAL. - Direct column refs in VIRTUAL expressions. SQLite does not allow generated columns to reference other generated columns or use subqueries. All VIRTUAL expressions reference base columns only.
- Tip-off prohibition at DB layer.
str.tipped_offandstor_report.tipped_offboth useCHECK(tipped_off = 0)— the only allowed value is 0. - Scaffold table pattern. Tables for enacted-but-not-yet-enforced regulations are clearly commented
-- SCAFFOLD: regulation pending / enforcement YYYY. Schemas are representative of the final regulation, not placeholder. - Index naming. Indexes prefixed with first 4–5 chars of table name (
idx_lcr_,idx_pad_, etc.) to avoid naming conflicts across the single-file DDL.