<?php

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

return new class extends Migration
{
    public function up(): void
    {
        DB::table('products')->whereNull('amadast_product_type_id')->update(['amadast_product_type_id' => 1]);

        Schema::table('products', function (Blueprint $table) {
            $table->unsignedInteger('amadast_product_type_id')->default(1)->change();
        });
    }

    public function down(): void
    {
        Schema::table('products', function (Blueprint $table) {
            $table->unsignedInteger('amadast_product_type_id')->default(null)->nullable()->change();
        });
    }
};
