Extend shift reporting and downtime analytics

This commit is contained in:
admin committed 2026-10-20 14:16:58 +02:00
1 parent 41a5ae7a63
commit 6e8eb6f50f
74 files changed
+5397 -238

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
-- Apply once before enabling the reconciliation service (also safe to reapply).
CREATE TABLE IF NOT EXISTS historical_assignment_audit (
id bigserial PRIMARY KEY,
machine_id text NOT NULL,
source_table text NOT NULL,
record_identity jsonb NOT NULL,
previous_order text NOT NULL,
new_order text NOT NULL,
run_id text NOT NULL,
reason text NOT NULL,
action text NOT NULL DEFAULT 'updated',
retained_run_id text,
reconciled_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
CHECK (previous_order <> new_order)
);
ALTER TABLE historical_assignment_audit
ADD COLUMN IF NOT EXISTS action text NOT NULL DEFAULT 'updated';
ALTER TABLE historical_assignment_audit
ADD COLUMN IF NOT EXISTS retained_run_id text;
CREATE INDEX IF NOT EXISTS historical_assignment_audit_machine_time_idx
ON historical_assignment_audit (machine_id, reconciled_at);
+17
View File
@@ -126,3 +126,20 @@ CREATE TABLE IF NOT EXISTS production_order_attribution_state (
started_at timestamptz NOT NULL,
ended_at timestamptz NULL
);
-- Apply once before enabling the reconciliation service (also safe to reapply).
CREATE TABLE IF NOT EXISTS historical_assignment_audit (
id bigserial PRIMARY KEY,
machine_id text NOT NULL,
source_table text NOT NULL,
record_identity jsonb NOT NULL,
previous_order text NOT NULL,
new_order text NOT NULL,
run_id text NOT NULL,
reason text NOT NULL,
action text NOT NULL DEFAULT 'updated',
retained_run_id text,
reconciled_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
CHECK (previous_order <> new_order)
);
CREATE INDEX IF NOT EXISTS historical_assignment_audit_machine_time_idx
ON historical_assignment_audit (machine_id, reconciled_at);