<?php

declare(strict_types=1);

namespace App\Domain\Test\Migrations;

use App\Framework\Database\ConnectionInterface;
use App\Framework\Database\Migration\Migration;
use App\Framework\Database\Migration\MigrationVersion;
use App\Framework\Database\Platform\SchemaBuilderFactory;
use App\Framework\Database\Platform\ValueObjects\TableOptions;

final readonly class CreatePerformanceTestTable implements Migration
{
    public function up(ConnectionInterface $connection): void
    {
        $schema = SchemaBuilderFactory::create($connection);

        $schema->createTable(
            'performance_test_table',
            [
                $schema->id(),
                $schema->string('name', 255)->notNull(),
                $schema->string('description', 500),
                $schema->timestamp('created_at'),
            ],
            TableOptions::default()
                ->withEngine('InnoDB')
                ->withCharset('utf8mb4')
                ->withCollation('utf8mb4_unicode_ci')
                ->withIfNotExists()
                ->withComment('Performance testing table for migration monitoring')
        );
    }

    public function down(ConnectionInterface $connection): void
    {
        $schema = SchemaBuilderFactory::create($connection);
        $schema->dropTable('performance_test_table', true);
    }

    public function getVersion(): MigrationVersion
    {
        return MigrationVersion::fromTimestamp("2024_12_27_214000");
    }

    public function getDescription(): string
    {
        return 'Create performance test table for migration monitoring';
    }
}
