<?php
/// file: database/migrations/002_create_projects.php

declare(strict_types=1);


return static function (PDO $pdo): void {
    $pdo->exec('CREATE TABLE IF NOT EXISTS projects (
      id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
      title VARCHAR(255) NOT NULL,
      slug VARCHAR(255) NOT NULL UNIQUE,
      client VARCHAR(255) NOT NULL DEFAULT "",
      year SMALLINT UNSIGNED NOT NULL,
      sector VARCHAR(120) NOT NULL DEFAULT "",
      category VARCHAR(64) NOT NULL DEFAULT "immersive web",
      services TEXT NULL,
      summary TEXT NOT NULL,
      challenge TEXT NOT NULL,
      creative_direction TEXT NOT NULL,
      process TEXT NOT NULL,
      outcomes TEXT NOT NULL,
      cover_type ENUM(\'image\',\'video\') NOT NULL DEFAULT \'image\',
      cover_path VARCHAR(512) NOT NULL DEFAULT "",
      status ENUM(\'draft\',\'published\') NOT NULL DEFAULT \'published\',
      sort_order INT NOT NULL DEFAULT 0,
      created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
      updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
      INDEX idx_category (category),
      INDEX idx_status (status)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci');
};
