Implement political office history logging: Added SQL logic to archive political office records upon expiration and deletion, ensuring historical tracking of office terms. Updated relevant queries to insert records into falukant_log.political_office_history for better compliance with data retention policies.
All checks were successful
Deploy yourpart (blue-green) / deploy (push) Successful in 1m33s

This commit is contained in:
Torsten Schulz (local)
2026-04-17 17:30:40 +02:00
parent 75a1e5b306
commit 0892e2db8b
3 changed files with 105 additions and 24 deletions

View File

@@ -0,0 +1,28 @@
-- Abgeschlossene politische Ämter (Amtsende, Neubesetzung, Entfernung) für Auswertung „Karrierehöchstwert“ / UI.
-- Wird vom YpDaemon vor Löschen aus falukant_data.political_office befüllt.
CREATE TABLE IF NOT EXISTS falukant_log.political_office_history (
id BIGSERIAL PRIMARY KEY,
character_id INTEGER NOT NULL,
office_type_id INTEGER NOT NULL,
region_id INTEGER,
start_date TIMESTAMPTZ NOT NULL,
end_date TIMESTAMPTZ NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
-- Tabelle kann bereits vom Backend existieren (ohne region_id o. Ä.): CREATE TABLE IF NOT EXISTS ergänzt keine Spalten.
ALTER TABLE falukant_log.political_office_history
ADD COLUMN IF NOT EXISTS region_id INTEGER;
CREATE INDEX IF NOT EXISTS idx_pol_office_hist_character
ON falukant_log.political_office_history (character_id);
CREATE INDEX IF NOT EXISTS idx_pol_office_hist_office_type
ON falukant_log.political_office_history (office_type_id);
CREATE INDEX IF NOT EXISTS idx_pol_office_hist_region
ON falukant_log.political_office_history (region_id);
COMMENT ON TABLE falukant_log.political_office_history IS
'Politische Amtszeiten nach Ende; start_date/end_date aus Amtszeile bzw. NOW() bei vorzeitigem Ende (YpDaemon).';