<?php
/// file: database/migrations/005_create_journal_posts.php

declare(strict_types=1);


return static function (PDO $pdo): void {
    $pdo->exec('CREATE TABLE IF NOT EXISTS journal_posts (
      id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
      title VARCHAR(255) NOT NULL,
      slug VARCHAR(255) NOT NULL UNIQUE,
      excerpt TEXT NOT NULL,
      body LONGTEXT NOT NULL,
      category VARCHAR(64) NOT NULL DEFAULT "studio",
      reading_time SMALLINT UNSIGNED NOT NULL DEFAULT 5,
      cover_path VARCHAR(512) NOT NULL DEFAULT "",
      status ENUM(\'draft\',\'published\') NOT NULL DEFAULT \'published\',
      published_at DATE NULL,
      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');
};
