-- Public club pages and read-only schedule publication controls.

ALTER TABLE game_groups
    ADD COLUMN public_slug VARCHAR(120),
    ADD COLUMN public_schedule_enabled BOOLEAN NOT NULL DEFAULT false,
    ADD COLUMN public_schedule_updated_at TIMESTAMPTZ;

ALTER TABLE sessions
    ADD COLUMN is_public BOOLEAN NOT NULL DEFAULT false;

CREATE UNIQUE INDEX ux_game_groups_public_slug
    ON game_groups (lower(public_slug))
    WHERE public_slug IS NOT NULL;

CREATE INDEX ix_sessions_public_schedule
    ON sessions (group_id, scheduled_at)
    WHERE is_public = true AND status <> 'Cancelled';
