CREATE TABLE IF NOT EXISTS notifications (
  id          UUID         PRIMARY KEY DEFAULT gen_random_uuid(),
  hotel_id    UUID         NOT NULL REFERENCES hotels(id) ON DELETE CASCADE,
  type        VARCHAR(50)  NOT NULL,
  title       TEXT         NOT NULL,
  body        TEXT         NOT NULL,
  booking_id  UUID         REFERENCES bookings(id)  ON DELETE SET NULL,
  room_id     UUID         REFERENCES rooms(id)     ON DELETE SET NULL,
  link        TEXT,
  is_read     BOOLEAN      NOT NULL DEFAULT false,
  created_at  TIMESTAMPTZ  NOT NULL DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS notifications_hotel_created_idx ON notifications(hotel_id, created_at DESC);
