BEGIN;

ALTER TABLE chat.room
    ADD COLUMN IF NOT EXISTS gender_restriction_id INTEGER,
    ADD COLUMN IF NOT EXISTS min_age INTEGER,
    ADD COLUMN IF NOT EXISTS max_age INTEGER,
    ADD COLUMN IF NOT EXISTS password VARCHAR(255),
    ADD COLUMN IF NOT EXISTS friends_of_owner_only BOOLEAN DEFAULT FALSE,
    ADD COLUMN IF NOT EXISTS required_user_right_id INTEGER;

UPDATE chat.room
SET friends_of_owner_only = FALSE
WHERE friends_of_owner_only IS NULL;

ALTER TABLE chat.room
    ALTER COLUMN friends_of_owner_only SET DEFAULT FALSE,
    ALTER COLUMN friends_of_owner_only SET NOT NULL;

COMMIT;
