CREATE DATABASE IF NOT EXISTS wedding CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
USE wedding;

CREATE TABLE sends (
  id INT AUTO_INCREMENT PRIMARY KEY,
  user_id INT NOT NULL,
  channel ENUM('sms','whatsapp') NOT NULL,
  payload TEXT,
  status ENUM('pending','sent','failed') DEFAULT 'pending',
  response TEXT,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);

CREATE TABLE scan_logs (
  id INT AUTO_INCREMENT PRIMARY KEY,
  user_id INT,
  scanned_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  action ENUM('verified','already_used','invalid') NOT NULL,
  note TEXT
);
