<?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('centro_trabajos', function (Blueprint $table) {
            $table->engine = "InnoDB";
            $table->bigIncrements('id');
            $table->string('nombre');
            $table->string('jefeArea')->nullable();
            $table->bigInteger('dependencia_id')->unsigned();
            $table->foreign('dependencia_id')->references('id')->on('dependencias')->onDelete("cascade");
            $table->timestamps();
        });
    }
    
    public function down(): void
    {
        Schema::table('centro_trabajos', function (Blueprint $table) {
            $table->dropForeign(['dependencia_id']);
        });
    
        Schema::dropIfExists('centro_trabajos');
    }
    
};
