-- Add static passwords which could be set via protected with HTTPS web interface

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 = 'users' AND n.nspname = 'auth' AND a.attname = 'web_password'
    ) THEN
        ALTER TABLE auth.users ADD COLUMN web_password TEXT NULL;
    END IF;

    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 = 'users' AND n.nspname = 'auth' AND a.attname = 'game_password'
    ) THEN
        ALTER TABLE auth.users ADD COLUMN game_password TEXT NULL;
    END IF;
END
$$;