Files
hotelsync/backend/migrations/009_guests.sql
HotelSync de4fb2126b Add Guests module: API integration + passport identification
- Migration 009: add passport_series, passport_number, rating to guests table
- Backend route /api/hotels/:slug/guests: list, get (with history), create/upsert by passport, update, delete
- Frontend GuestsPage: loads from API, passport tab in modal, add guest form, search by passport
- api.ts: add guests API methods and GuestApiType

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19 14:03:04 +03:00

13 lines
572 B
SQL

-- 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;