<?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
    {
        if (Schema::hasTable('supplier_returns')) {
            return;
        }

        Schema::create('supplier_returns', function (Blueprint $table) {
            $table->id();
            $table->string('return_no', 50)->nullable()->index();
            $table->string('supplier_name', 150)->index();
            $table->date('return_date')->index();
            $table->text('notes')->nullable();
            $table->decimal('total', 12, 2)->default(0);
            $table->timestamps();
        });
    }

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