Refactor BundeslandRepository, implement V012 migration for Reiter master data changes, harmonize domain models, resolve repository interface inconsistencies, and enhance ZNS import with relational mapping improvements.

This commit is contained in:
2026-04-06 16:51:14 +02:00
parent 0ae9a1f1b8
commit 1b6f8e7c59
8 changed files with 75 additions and 28 deletions
@@ -36,16 +36,15 @@ ALTER TABLE reiter ADD COLUMN IF NOT EXISTS nation_id UUID;
-- Fremdschlüssel-Constraints
ALTER TABLE reiter ADD CONSTRAINT fk_reiter_verein FOREIGN KEY (verein_id) REFERENCES verein(verein_id);
ALTER TABLE reiter ADD CONSTRAINT fk_reiter_bundesland FOREIGN KEY (bundesland_id) REFERENCES bundesland(id);
ALTER TABLE reiter ADD CONSTRAINT fk_reiter_nation FOREIGN KEY (nation_id) REFERENCES land(id);
ALTER TABLE reiter ADD CONSTRAINT fk_reiter_lizenz_reiter FOREIGN KEY (reiter_id) REFERENCES reiter(reiter_id) ON DELETE CASCADE;
ALTER TABLE reiter ADD CONSTRAINT fk_reiter_nation FOREIGN KEY (nation_id) REFERENCES land(land_id);
ALTER TABLE reiter_lizenz ADD CONSTRAINT fk_reiter_lizenz_reiter FOREIGN KEY (reiter_id) REFERENCES reiter(reiter_id) ON DELETE CASCADE;
-- 3. Daten gemäß OEPS-Spezifikation korrigieren (für Österreich)
DO $$
DECLARE
austria_id UUID;
BEGIN
SELECT id INTO austria_id FROM land WHERE iso_alpha2_code = 'AT';
SELECT land_id INTO austria_id FROM land WHERE iso_alpha2_code = 'AT';
IF austria_id IS NOT NULL THEN
-- Bestehende Einträge löschen oder aktualisieren