-- Psikotest Online - Minimal schema (demo)
-- MySQL 5.7+/8.0 recommended

CREATE TABLE IF NOT EXISTS settings (
  `key` VARCHAR(100) PRIMARY KEY,
  `value` TEXT NOT NULL,
  `type` VARCHAR(20) NOT NULL DEFAULT 'string',
  updated_at TIMESTAMP NULL DEFAULT NULL,
  created_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS candidate_tokens (
  id INT AUTO_INCREMENT PRIMARY KEY,
  token VARCHAR(128) NOT NULL UNIQUE,
  candidate_name VARCHAR(150) NULL,
  campaign_name VARCHAR(150) NULL,
  expires_at DATETIME NOT NULL,
  attempt_count INT NOT NULL DEFAULT 0,
  used_at DATETIME NULL,
  created_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- (Next tables you will add)
-- companies, users, campaigns, candidates, tests, questions, choices, responses, scoring_rules, results, reports, audit_logs
