Files
yourpart-daemon/migrations/016_falukant_log_political_office_history.sql
Torsten Schulz (local) 35377e3b59
Some checks failed
Deploy yourpart (blue-green) / deploy (push) Failing after 1m22s
Wahlproblem gefixt
2026-06-06 12:35:27 +02:00

36 lines
1.6 KiB
SQL

-- 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(),
updated_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;
ALTER TABLE falukant_log.political_office_history
ADD COLUMN IF NOT EXISTS created_at TIMESTAMPTZ NOT NULL DEFAULT NOW();
ALTER TABLE falukant_log.political_office_history
ADD COLUMN IF NOT EXISTS updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW();
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).';