<?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('property_assessments', function (Blueprint $table) {
            $table->unsignedBigInteger('Generated_By')->nullable()->after('your_previous_column');

            $table->foreign('Generated_By')
                  ->references('Usr_Id')
                  ->on('user_master')
                  ->nullOnDelete()
                  ->cascadeOnUpdate();
        });
    }

    public function down(): void
    {
        Schema::table('property_assessments', function (Blueprint $table) {
            $table->dropForeign(['Generated_By']);
            $table->dropColumn('Generated_By');
        });
    }
};
