<?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
    {
        // Make old title column nullable in competency_units
        Schema::table('competency_units', function (Blueprint $table) {
            $table->string('title')->nullable()->change();
        });

        // Make old description column nullable in competencies
        Schema::table('competencies', function (Blueprint $table) {
            $table->text('description')->nullable()->change();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        // Revert title to NOT NULL
        Schema::table('competency_units', function (Blueprint $table) {
            $table->string('title')->nullable(false)->change();
        });

        // Revert description to NOT NULL
        Schema::table('competencies', function (Blueprint $table) {
            $table->text('description')->nullable(false)->change();
        });
    }
};
