<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    public function up(): void
    {
        Schema::table('artworks', function (Blueprint $table) {
            $table->string('hash', 128)->nullable()->unique()->after('mime_type');
            $table->string('file_ext', 16)->nullable()->after('hash');
            $table->string('thumb_ext', 16)->nullable()->after('file_ext');
        });
    }

    public function down(): void
    {
        Schema::table('artworks', function (Blueprint $table) {
            $table->dropUnique(['hash']);
            $table->dropColumn(['hash', 'file_ext', 'thumb_ext']);
        });
    }
};
