<?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('artwork_versions', function (Blueprint $table): void {
            if (! Schema::hasColumn('artwork_versions', 'snapshot_json')) {
                $table->json('snapshot_json')->nullable()->after('change_note');
            }
        });
    }

    public function down(): void
    {
        Schema::table('artwork_versions', function (Blueprint $table): void {
            if (Schema::hasColumn('artwork_versions', 'snapshot_json')) {
                $table->dropColumn('snapshot_json');
            }
        });
    }
};