-- Script SQL para crear la base de datos manualmente
-- Ejecutar esto en MySQL si prefieres no usar el endpoint /api/init-db

CREATE DATABASE IF NOT EXISTS invitacion_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

USE invitacion_db;

CREATE TABLE IF NOT EXISTS rsvps (
  id INT AUTO_INCREMENT PRIMARY KEY,
  invitation_id INT NOT NULL,
  family_name VARCHAR(255),
  guest_name VARCHAR(255),
  phone VARCHAR(32),
  guests_count INT DEFAULT 1,
  message_text TEXT,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  INDEX idx_invitation_id (invitation_id),
  UNIQUE KEY uniq_invitation_phone (invitation_id, phone),
  CONSTRAINT fk_rsvps_invitation FOREIGN KEY (invitation_id) REFERENCES invitations(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
