<?php
declare(strict_types=1);

use Celena\Core\Database\Blueprint;
use Celena\Core\Database\Connection;
use Celena\Core\Database\Schema;

return function (Schema $schema, Connection $conn): void {
    $schema->create('celena_news', function (Blueprint $t) {
        $t->id();
        $t->string('slug', 191);
        $t->string('title', 255);
        $t->text('short')->nullable();
        $t->text('body')->nullable();
        $t->string('body_format', 16)->default('markdown');
        $t->string('status', 16)->default('draft');
        $t->bigInteger('category_id')->nullable();
        $t->bigInteger('author_id')->nullable();
        $t->string('cover', 500)->nullable();
        $t->string('seo_title', 255)->nullable();
        $t->text('seo_description')->nullable();
        $t->string('og_image', 500)->nullable();
        $t->integer('views')->default(0);
        $t->integer('comments_count')->default(0);
        $t->datetime('published_at')->nullable();
        $t->datetime('created_at')->nullable();
        $t->datetime('updated_at')->nullable();
        $t->unique('slug');
        $t->index('status');
        $t->index('category_id');
        $t->index('published_at');
    });
};
