<?php
/// file: database/migrations/011_create_job_applications.php

declare(strict_types=1);


return static function (PDO $pdo): void {
    $pdo->exec('CREATE TABLE IF NOT EXISTS job_applications (
      id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
      career_id INT UNSIGNED NULL,
      full_name VARCHAR(255) NOT NULL,
      email VARCHAR(255) NOT NULL,
      portfolio_url VARCHAR(512) NOT NULL DEFAULT "",
      message TEXT NOT NULL,
      status ENUM(\'new\',\'reviewed\',\'archived\') NOT NULL DEFAULT \'new\',
      created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
      CONSTRAINT fk_ja_career FOREIGN KEY (career_id) REFERENCES careers(id) ON DELETE SET NULL,
      INDEX idx_status (status)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci');
};
