<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class Version20260221000300 extends AbstractMigration
{
    public function getDescription(): string
    {
        return 'Creates tag_rebuild_job table (MariaDB compatible, binary UUID)';
    }

    public function up(Schema $schema): void
    {
        $this->addSql("
            CREATE TABLE IF NOT EXISTS tag_rebuild_job (
                id BINARY(16) NOT NULL,
                status VARCHAR(16) NOT NULL,
                created_at DATETIME NOT NULL,
                started_at DATETIME DEFAULT NULL,
                finished_at DATETIME DEFAULT NULL,
                error_message TEXT DEFAULT NULL,
                PRIMARY KEY(id),
                INDEX idx_tag_rebuild_job_status (status),
                INDEX idx_tag_rebuild_job_created_at (created_at)
            ) ENGINE=InnoDB
              DEFAULT CHARSET=utf8mb4
              COLLATE=utf8mb4_unicode_ci
        ");
    }

    public function down(Schema $schema): void
    {
        $this->addSql("DROP TABLE tag_rebuild_job");
    }
}