Persist material efficiency snapshots

This commit is contained in:
2026-09-06 08:23:28 +02:00
parent c411581a1a
commit ed0e20a04b
10 changed files with 851 additions and 32 deletions
+21
View File
@@ -11,3 +11,24 @@ CREATE TABLE IF NOT EXISTS material_consumption_snapshots (
-- Machine time series across orders; the primary key covers a specific order.
CREATE INDEX IF NOT EXISTS material_consumption_snapshots_machine_time_idx
ON material_consumption_snapshots (calculation_id, machine_id, timestamp);
CREATE TABLE IF NOT EXISTS material_efficiency_snapshots (
erp_feedback_timestamp timestamptz NOT NULL,
material_snapshot_timestamp timestamptz NOT NULL,
calculation_id text NOT NULL,
machine_id text NOT NULL,
workplace text NOT NULL,
erp_production_order text NOT NULL,
enlyze_production_order text NOT NULL,
article_number text NULL,
article_description text NULL,
nominal_width_m double precision NULL,
good_quantity_m2 double precision NOT NULL,
material_consumption_kg double precision NOT NULL,
material_consumption_kg_per_m2 double precision NOT NULL,
material_consumption_g_per_m2 double precision NOT NULL,
PRIMARY KEY (calculation_id, machine_id, enlyze_production_order, erp_feedback_timestamp)
);
CREATE INDEX IF NOT EXISTS material_efficiency_snapshots_machine_time_idx
ON material_efficiency_snapshots (calculation_id, machine_id, erp_feedback_timestamp);