<?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::create('suppliers', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('farm_id')->default(1);
            $table->string('name', 200);
            $table->string('nickname', 100)->nullable();
            $table->string('business_name', 200)->nullable();
            $table->text('address')->nullable();
            $table->string('landmark', 200)->nullable();
            $table->string('email', 200)->nullable();
            $table->string('phone', 50)->nullable();
            $table->text('notes')->nullable();
            $table->boolean('is_flagged')->default(false);
            $table->string('flag_reason', 500)->nullable();
            $table->timestamps();
            $table->softDeletes();

            $table->index('farm_id');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('suppliers');
    }
};
