<?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::table('ordenes_trabajo', function (Blueprint $table) {
            $table->foreignId('frecuencia_id')->nullable()->after('plan_id')
                ->constrained('frecuencias')->nullOnDelete();
        });
    }

    public function down(): void
    {
        Schema::table('ordenes_trabajo', function (Blueprint $table) {
            $table->dropForeign(['frecuencia_id']);
            $table->dropColumn('frecuencia_id');
        });
    }
};
