<?php
// database/migrations/[timestamp]_fix_parent_id_nullable_in_users_table.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
    {
        // Untuk MySQL
        DB::statement('ALTER TABLE `users` MODIFY `parent_id` BIGINT UNSIGNED NULL');
        
        // Atau jika menggunakan Schema Builder
        Schema::table('users', function (Blueprint $table) {
            $table->foreignId('parent_id')->nullable()->change();
        });
    }

    public function down(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->foreignId('parent_id')->nullable(false)->change();
        });
    }
};