-- Migration 009 — Add passport_series, passport_number and rating to guests

ALTER TABLE guests
  ADD COLUMN IF NOT EXISTS passport_series VARCHAR(20),
  ADD COLUMN IF NOT EXISTS passport_number VARCHAR(20),
  ADD COLUMN IF NOT EXISTS rating          INTEGER NOT NULL DEFAULT 3
    CHECK (rating BETWEEN 1 AND 5);

-- Unique index: one profile per passport (series+number) per hotel
CREATE UNIQUE INDEX IF NOT EXISTS idx_guests_passport_unique
  ON guests(hotel_id, passport_series, passport_number)
  WHERE passport_series IS NOT NULL AND passport_number IS NOT NULL;
