<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('categoria_proveedor', function (Blueprint $table) {
            $table->id('idCategoriaProveedor');
            $table->string('nombre', 100);
            $table->tinyInteger('state')->default(1);
            $table->timestamps();
            $table->softDeletes();
        });

        Schema::create('proveedor', function (Blueprint $table) {
            $table->id('idProveedor');
            $table->string('ruc', 11)->unique();
            $table->string('razonSocial', 255);
            $table->string('direccion', 255);
            $table->string('telefono', 20)->nullable();
            $table->string('email', 150)->nullable();
            $table->string('paginaWeb', 255)->nullable();
            $table->enum('tipoDocumento', ['DNI', 'CARNET_EXTRANJERIA']);
            $table->string('documentoRepresentante', 12)->nullable();
            $table->string('nombreRepresentante', 150)->nullable();
            $table->unsignedBigInteger('idCategoriaProveedor')->nullable();
            $table->tinyInteger('state')->default(1);
            $table->timestamps();
            $table->softDeletes();

            $table->foreign('idCategoriaProveedor')->references('idCategoriaProveedor')->on('categoria_proveedor');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('proveedor');
        Schema::dropIfExists('categoria_proveedor');
    }
};
