-- Add field to game to show team info

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 = 'games' AND n.nspname = 'games' AND a.attname = 'is_teamed'
    ) THEN
        ALTER TABLE games.games ADD COLUMN is_teamed BOOLEAN NOT NULL DEFAULT FALSE; 
    END IF;
END
$$;