<?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('lc_modules', function (Blueprint $table) {
            $table->string('lc_payment_term')->nullable()->after('supplier_id');
            $table->unsignedBigInteger('cnf_id')->nullable()->after('lc_payment_term');
            $table->foreign('cnf_id')->references('id')->on('cnfs')->onDelete('set null');
        });
    }

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