-- Migration 019: Add recurring event support
-- Adds wiederholung (recurrence) config and parent link for generated instances

ALTER TABLE veranstaltungen
  ADD COLUMN IF NOT EXISTS wiederholung JSONB,
  ADD COLUMN IF NOT EXISTS wiederholung_parent_id UUID REFERENCES veranstaltungen(id) ON DELETE SET NULL;

CREATE INDEX IF NOT EXISTS idx_veranstaltungen_parent_id
  ON veranstaltungen(wiederholung_parent_id);

COMMENT ON COLUMN veranstaltungen.wiederholung IS 'JSON config for recurring events: {typ, intervall?, bis, wochentag?}';
COMMENT ON COLUMN veranstaltungen.wiederholung_parent_id IS 'Links generated recurrence instances back to the parent event';
