<?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('purchases', function (Blueprint $table) {
            $table->id();
            $table->string('invoice_no', 50)->nullable()->index();
            $table->string('supplier_name', 150)->index();
            $table->date('purchase_date')->nullable()->index();
            $table->text('notes')->nullable();
            $table->decimal('grand_total', 12, 2)->default(0);
            $table->timestamp('created_at')->nullable()->useCurrent();
        });
    }

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