Files
hotelsync/backend/migrations/036_channels_ru.sql

32 lines
799 B
SQL

-- Replace old channel constraint with Russian market channels
ALTER TABLE channels DROP CONSTRAINT IF EXISTS channels_name_check;
ALTER TABLE channels ADD CONSTRAINT channels_name_check
CHECK (name IN (
'booking_com',
'yandex_travel',
'ostrovok',
'sutochno',
'avito',
'bronevik',
'hotels101',
'onetwotrip'
));
-- Remove old non-RU channels from all hotels
DELETE FROM channels WHERE name IN ('airbnb', 'expedia', 'vrbo');
-- Add new Russian channels for all existing hotels (skip if already exists)
INSERT INTO channels (hotel_id, name)
SELECT h.id, c.name
FROM hotels h
CROSS JOIN (VALUES
('yandex_travel'),
('ostrovok'),
('sutochno'),
('avito'),
('bronevik'),
('hotels101'),
('onetwotrip')
) AS c(name)
ON CONFLICT (hotel_id, name) DO NOTHING;