CREATE TABLE IF NOT EXISTS rsvp_responses (
  id INT UNSIGNED NOT NULL AUTO_INCREMENT,
  event_id VARCHAR(80) NOT NULL,
  full_name VARCHAR(160) NOT NULL,
  email VARCHAR(190) NOT NULL,
  phone VARCHAR(60) DEFAULT NULL,
  category VARCHAR(60) NOT NULL DEFAULT '',
  attendance ENUM('yes','no') NOT NULL,
  party_size TINYINT UNSIGNED NOT NULL DEFAULT 0,
  note TEXT DEFAULT NULL,
  ip_address VARCHAR(45) DEFAULT NULL,
  user_agent VARCHAR(255) DEFAULT NULL,
  email_sent TINYINT(1) NOT NULL DEFAULT 0,
  email_error TEXT DEFAULT NULL,
  notification_sent TINYINT(1) NOT NULL DEFAULT 0,
  notification_error TEXT DEFAULT NULL,
  created_at DATETIME NOT NULL,
  updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (id),
  UNIQUE KEY uniq_event_email (event_id, email),
  KEY idx_event_attendance (event_id, attendance),
  KEY idx_created_at (created_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
