-- Restart-safe player-scoped assignment projections. The signed manifest and -- join authorisation are persisted only after the allocator/manifest gate has -- succeeded; clients still receive them only through an authenticated owner -- read. CREATE TABLE assignments ( match_id TEXT NOT NULL, player_id TEXT NOT NULL, allocation_id TEXT NOT NULL, server_id TEXT NOT NULL, slot INTEGER NOT NULL CHECK (slot BETWEEN 0 AND 5), region TEXT NOT NULL CHECK (region IN ('EU', 'NA')), client_build TEXT NOT NULL, protocol_version INTEGER NOT NULL CHECK (protocol_version > 0), transport TEXT NOT NULL CHECK (transport IN ('enet', 'steam_sdr')), endpoint TEXT NOT NULL, join_authorisation TEXT NOT NULL, manifest_digest BYTEA NOT NULL, expires_at TIMESTAMPTZ NOT NULL, revision BIGINT NOT NULL DEFAULT 0 CHECK (revision >= 0), created_at TIMESTAMPTZ NOT NULL DEFAULT now(), PRIMARY KEY (match_id, player_id), FOREIGN KEY (match_id, player_id) REFERENCES match_participants(match_id, player_id), UNIQUE (match_id, slot) ); CREATE INDEX assignments_player_expiry ON assignments (player_id, expires_at);