-- sql/schema.sql
CREATE TABLE IF NOT EXISTS invites (
  id INT AUTO_INCREMENT PRIMARY KEY,
  template_id INT DEFAULT 1,
  slug VARCHAR(255) UNIQUE,
  bride VARCHAR(255),
  groom VARCHAR(255),
  date DATE,
  time VARCHAR(20),
  venue TEXT,
  map TEXT,
  description TEXT,
  photo_path VARCHAR(255),
  created_at DATETIME
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS photos (
  id INT AUTO_INCREMENT PRIMARY KEY,
  invite_id INT NOT NULL,
  path VARCHAR(255),
  uploaded_at DATETIME,
  FOREIGN KEY (invite_id) REFERENCES invites(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS rsvps (
  id INT AUTO_INCREMENT PRIMARY KEY,
  invite_id INT NOT NULL,
  name VARCHAR(255),
  contact VARCHAR(255),
  attend ENUM('yes','no') DEFAULT 'yes',
  created_at DATETIME,
  FOREIGN KEY (invite_id) REFERENCES invites(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS admin (
  id INT AUTO_INCREMENT PRIMARY KEY,
  email VARCHAR(255) UNIQUE,
  password VARCHAR(255)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- create admin must be done via tools/create_admin.php or manually
