2.1 KiB
2.1 KiB
Accounting Canonical Schema (Layer 4)
Date: 2026-03-23
Status: implemented as MVP store (canonical_layer/store.py)
1. Purpose
Canonical schema is a normalized read-only store for accounting semantics extracted from 1C. It decouples heavy analytics from live query bridge.
2. Physical store
Current implementation supports SQLAlchemy URLs:
- default local:
sqlite:///X:/1C/NDC_1C/data/canonical_store.db - production target: PostgreSQL URL
3. Tables
canonical_entities
Main canonical facts table.
Fields:
source_entity(original 1C/OData entity set)source_id(stable source key)display_name(best effort label)attributes_json(raw source payload)first_seen_atupdated_atlast_refresh_run_id
Constraint:
- unique key on (
source_entity,source_id)
canonical_links
Graph edges inferred from reference-like fields.
Fields:
source_entitysource_idrelation(currentlyreference)target_entitytarget_idsource_fieldupdated_atlast_refresh_run_id
refresh_runs
Operational run log for extraction/refresh jobs.
Fields:
idmode(historical,incremental,targeted)status(running,success,partial_success,failed)started_at,finished_atrequested_entity_sets_jsondate_from,date_tolimit_per_setrecords_read,entities_written,links_written,checkpoints_updateddetails_json,error_message
refresh_checkpoints
Per-entity-set watermark/checkpoint state.
Fields:
entity_set(PK)last_success_atlast_refresh_run_idlast_date_from,last_date_to
4. Entity model mapping
Current canonical model maps into:
OrganizationCounterpartyContractAccountSubcontoDocumentPostingRegisterMovementPeriod
Mapping source:
canonical_layer/mappers.py
5. Known limitations (MVP)
attributes_jsonstores source row as-is; no typed column model yet.- Links are heuristic until per-configuration adapters are added.
- No dedicated partitioning strategy yet (planned for PostgreSQL stage).