CREATE TABLE reservation_details (
  idReservation           INT             NOT NULL,
  idEntityCompany         INT             NOT NULL,
  companyName             VARCHAR(255)    NULL,
  idRequesterCompany      INT             NULL,
  requesterCompanyName    VARCHAR(255)    NULL,
  groupName               VARCHAR(255)    NULL,
  contactName             VARCHAR(255)    NULL,
  contact1                VARCHAR(100)    NULL,
  contact2                VARCHAR(100)    NULL,
  dateAdd                 DATETIME        NULL,
  dateUp                  DATETIME        NULL,
  creditState             VARCHAR(50)     NULL,
  notes                   JSON            NULL COMMENT 'array de objetos { note }',
  rooms                   JSON            NULL COMMENT 'array de quartos com requirementReservation',
  guests                  JSON            NULL COMMENT 'array de hóspedes com notes',
  commissions             JSON            NULL COMMENT 'array de comissões',
  revenueManagement       JSON            NULL COMMENT 'objeto revenueManagement',
  raw_json                JSON            NOT NULL COMMENT 'payload bruto completo',
  PRIMARY KEY (idReservation, idEntityCompany),
  CONSTRAINT fk_reservation_details
    FOREIGN KEY (idReservation, idEntityCompany)
    REFERENCES reservations(idReservation, idEntity)
    ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
