-- HotelSync Migration 002 — NetUP IPTV Integration
-- Отдельные таблицы под модуль "Приветствие на TV"

CREATE TABLE IF NOT EXISTS netup_settings (
  hotel_id         UUID        PRIMARY KEY REFERENCES hotels(id) ON DELETE CASCADE,
  server_url       TEXT        NOT NULL DEFAULT '',
  username         TEXT        NOT NULL DEFAULT 'admin',
  password         TEXT        NOT NULL DEFAULT '',
  default_language TEXT        NOT NULL DEFAULT 'ru_RU',
  enabled          BOOLEAN     NOT NULL DEFAULT true,
  created_at       TIMESTAMPTZ NOT NULL DEFAULT NOW(),
  updated_at       TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

-- Сопоставление: номер в PMS → номер в NetUP
CREATE TABLE IF NOT EXISTS netup_room_mapping (
  hotel_id          UUID    NOT NULL REFERENCES hotels(id) ON DELETE CASCADE,
  pms_room_id       UUID    NOT NULL REFERENCES rooms(id) ON DELETE CASCADE,
  netup_room_number TEXT    NOT NULL,
  PRIMARY KEY (hotel_id, pms_room_id)
);
