-- +goose Up
ALTER TABLE recommendations ADD COLUMN IF NOT EXISTS rms_server_id UUID;
CREATE INDEX IF NOT EXISTS idx_recommendations_server_id ON recommendations(rms_server_id);

-- Удаляем старые записи без server_id (они невалидны)
DELETE FROM recommendations WHERE rms_server_id IS NULL;

-- Делаем поле NOT NULL после очистки
ALTER TABLE recommendations ALTER COLUMN rms_server_id SET NOT NULL;

-- +goose Down
ALTER TABLE recommendations DROP COLUMN IF EXISTS rms_server_id;
