Introduce tournament structure management for Entries Service:
- Add multi-layered entity support for `Turniere`, `Bewerbe`, and `Abteilungen` with tenant isolation. - Implement Flyway schema migrations with constraints, indices, and default values for `Turniere`. - Add Kotlin repositories and services for CRUD operations and validation across entities. - Ensure tenant-safe transactions and implement new exception handling for `LockedException` and `ValidationException`. - Provide REST APIs with controllers for managing lifecycle, hierarchy, and relationships between entities (`Turniere`, `Bewerbe`, and `Abteilungen`). - Update Spring configuration with dependency wiring for new services and repositories.
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
-- V3: Add status and published_at to turniere, with constraints and index
|
||||
-- Context: Roadmap B-1 / A-2 Ergänzung V3
|
||||
|
||||
-- Add columns if not exist (compatible with Postgres >= 9.6)
|
||||
ALTER TABLE IF EXISTS turniere
|
||||
ADD COLUMN IF NOT EXISTS status VARCHAR(16) NOT NULL DEFAULT 'DRAFT';
|
||||
|
||||
ALTER TABLE IF EXISTS turniere
|
||||
ADD COLUMN IF NOT EXISTS published_at TIMESTAMP WITH TIME ZONE NULL;
|
||||
|
||||
-- Add CHECK constraint for valid status values (idempotent)
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM pg_constraint c
|
||||
JOIN pg_class t ON c.conrelid = t.oid
|
||||
WHERE t.relname = 'turniere' AND c.conname = 'chk_turniere_status_valid'
|
||||
) THEN
|
||||
ALTER TABLE turniere
|
||||
ADD CONSTRAINT chk_turniere_status_valid CHECK (status IN ('DRAFT','PUBLISHED'));
|
||||
END IF;
|
||||
END$$;
|
||||
|
||||
-- Backfill existing rows to ensure consistent values (no-op if default already applied)
|
||||
UPDATE turniere SET status = COALESCE(status, 'DRAFT') WHERE status IS NULL;
|
||||
|
||||
-- Index to speed up filtering by status
|
||||
CREATE INDEX IF NOT EXISTS idx_turniere_status ON turniere(status);
|
||||
|
||||
-- Note: We intentionally keep the DEFAULT 'DRAFT' for safer inserts.
|
||||
Reference in New Issue
Block a user