<?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('bundles', function (Blueprint $table) {
            $table->dropForeign(['tenant_codigo']);
        });

        Schema::table('bundles', function (Blueprint $table) {
            $table->string('tenant_codigo')->change();
            $table->foreign('tenant_codigo')->references('codigo')->on('tenants')->onDelete('cascade');
        });
    }

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

        Schema::table('bundles', function (Blueprint $table) {
            $table->string('tenant_codigo', 10)->change();
            $table->foreign('tenant_codigo')->references('codigo')->on('tenants')->onDelete('cascade');
        });
    }
};
