-- Add field for delegate player:
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM pg_class c
INNER JOIN pg_namespace n ON n.oid = c.relnamespace
INNER JOIN pg_attribute a ON a.attrelid = c.oid
WHERE c.relname = 'players' AND n.nspname = 'games' AND a.attname = 'delegate_name'
) THEN
games.players ADD COLUMN delegate_name CITEXT REFERENCES auth.users(player_name) NULL;
END IF;
END
$$;