Files
ems/db/migration/V037__audit_day_lock.sql
Dusan Vojacek 5fcc47bce2
All checks were successful
test / smoke-test (push) Successful in 5s
deploy / deploy (push) Successful in 11s
implementace Ekonomiky
2026-04-05 20:10:43 +02:00

24 lines
1.0 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- =============================================================
-- V037 audit_day_lock
-- Zamknuté (finalizované) denní ekonomické výsledky.
-- =============================================================
CREATE TABLE ems.audit_day_lock (
site_id INT NOT NULL REFERENCES ems.site(id),
day_local DATE NOT NULL,
import_cost_czk NUMERIC(12,2) NOT NULL,
export_revenue_czk NUMERIC(12,2) NOT NULL,
net_cost_czk NUMERIC(12,2) NOT NULL,
green_bonus_czk NUMERIC(12,2) NOT NULL DEFAULT 0,
total_balance_czk NUMERIC(12,2) NOT NULL,
locked_at TIMESTAMPTZ NOT NULL DEFAULT now(),
locked_by TEXT NOT NULL DEFAULT 'user',
notes TEXT,
PRIMARY KEY (site_id, day_local)
);
COMMENT ON TABLE ems.audit_day_lock IS
'Zamknuté (finalizované) denní ekonomické výsledky.
Když řádek existuje, frontend zobrazí tyto hodnoty místo dynamických z vw_economics_daily.
Uživatel zamkne den, až má jistotu o cenách snapshot aktuálních dynamických hodnot.';