<?php
/// file: database/migrations/003_create_project_media.php

declare(strict_types=1);


return static function (PDO $pdo): void {
    $pdo->exec('CREATE TABLE IF NOT EXISTS project_media (
      id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
      project_id INT UNSIGNED NOT NULL,
      type ENUM(\'image\',\'video\') NOT NULL DEFAULT \'image\',
      path VARCHAR(512) NOT NULL,
      caption VARCHAR(255) NULL,
      sort_order INT NOT NULL DEFAULT 0,
      created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
      CONSTRAINT fk_pm_project FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE,
      INDEX idx_project (project_id)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci');
};
