<?php

namespace App\Domain\Media\Migrations;

use App\Framework\Database\ConnectionInterface;
use App\Framework\Database\Migration\Migration;

final readonly class CreateImageSlotsTable implements Migration
{

    public function up(ConnectionInterface $connection): void
    {
        $sql = <<<SQL
            CREATE TABLE IF NOT EXISTS image_slots (
                id              INT AUTO_INCREMENT,
                image_id        VARCHAR(26) NOT NULL,
                slot_name       VARCHAR(50) NOT NULL,
                created_at      TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
                updated_at      TIMESTAMP NULL DEFAULT NULL,

                PRIMARY KEY (id)
                )
                ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
SQL;

        $connection->query($sql);
    }

    public function down(ConnectionInterface $connection): void
    {
        $connection->execute("DROP TABLE IF EXISTS image_slots");
    }

    public function getVersion(): string
    {
        return "004";
    }

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