CREATE TABLE IF NOT EXISTS notification_settings ( id BIGSERIAL PRIMARY KEY, account_id BIGINT NOT NULL, user_id BIGINT NOT NULL, email_flags INTEGER NOT NULL DEFAULT 0, push_flags INTEGER NOT NULL DEFAULT 0, created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), deleted_at TIMESTAMPTZ DEFAULT NULL ); CREATE INDEX IF NOT EXISTS idx_notification_settings_account_user ON notification_settings (account_id, user_id); CREATE INDEX IF NOT EXISTS idx_notification_settings_deleted_at ON notification_settings (deleted_at);