<?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('bienes', function (Blueprint $table) {
            $table->engine = "InnoDB";
            $table->bigIncrements('id');
            $table->string('inventario')->unique();
            $table->string('marca');
            $table->string('modelo');
            $table->string('serie');
            $table->string('bien');
            $table->string('descripcion');
            $table->string('observaciones')->nullable();
            $table->BigInteger('situacion_id')->unsigned();
            $table->foreign('situacion_id')->references('id')->on('situacions')->onDelete("cascade");
            $table->BigInteger('categoria_partida_id')->unsigned();
            $table->foreign('categoria_partida_id')->references('id')->on('categorias_partidas')->onDelete("cascade");
            $table->BigInteger('conservacion_id')->unsigned();
            $table->foreign('conservacion_id')->references('id')->on('conservacions')->onDelete("cascade");
            $table->BigInteger('estatus_id')->unsigned();
            $table->foreign('estatus_id')->references('id')->on('estatuses')->onDelete("cascade");
            $table->BigInteger('tipoBien_id')->unsigned();
            $table->foreign('tipoBien_id')->references('id')->on('tipoBienes')->onDelete("cascade");
            $table->decimal('costo', 15, 2);
            // $table->date('fechaAlta');
            $table->BigInteger('centro_trabajo_id')->unsigned();
            $table->foreign('centro_trabajo_id')->references('id')->on('centro_trabajos')->onDelete("cascade");
            // $table->BigInteger('categoria_id')->unsigned();
            // $table->foreign('categoria_id')->references('id')->on('categorias')->onDelete("cascade");
            $table->bigInteger('factura_id')->unsigned();
            $table->foreign('factura_id')->references('id')->on('facturas')->onDelete('cascade');
            $table->timestamps();
        });
    }

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