<?php

declare(strict_types=1);

namespace App\Domain\Media\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 CreateImageSlotsTable implements Migration
{
    public function up(ConnectionInterface $connection): void
    {
        $schema = SchemaBuilderFactory::create($connection);

        $schema->createTable(
            'image_slots',
            [
            $schema->id(),
            $schema->string('image_id', 26)->notNull(),
            $schema->string('slot_name', 50)->notNull(),
            $schema->timestamp('created_at')->notNull()->withDefault('CURRENT_TIMESTAMP'),
            $schema->timestamp('updated_at')->withDefault(null),
        ],
            TableOptions::default()
            ->withEngine('InnoDB')
            ->withCharset('utf8mb4')
            ->withCollation('utf8mb4_unicode_ci')
            ->withIfNotExists()
            ->withComment('Image slots table for image slot management')
        );
    }

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

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

    public function getDescription(): string
    {
        return "Create Image Slot Table";
    }
}
