<?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();

            // Relations
            $table->foreignId('address_id')->nullable()->constrained('addresses')->nullOnDelete();
            $table->foreignId('contact_id')->nullable()->constrained('contacts')->nullOnDelete();

            // Identity
            $table->string('name');
            $table->string('slug')->unique();
            $table->string('contact_person')->nullable();

            // Media
            $table->text('notes')->nullable();

            // Status
            $table->boolean('status')->default(false);
            $table->timestamps();
            $table->softDeletes();

            $table->index(['name']);
            $table->index(['status']);
        });
    }

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