<?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('import_rows', function (Blueprint $table) {
            if (! Schema::hasColumn('import_rows', 'raw_sha1')) {
                $table->string('raw_sha1', 40)->nullable()->after('fingerprint')->index();
            }
        });
    }

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