<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('tickets', function (Blueprint $table): void {
            $table->string('name')->nullable()->change();
            $table->text('description')->nullable()->change();
        });
    }

    public function down(): void
    {
        DB::table('tickets')->whereNull('name')->update(['name' => '']);
        DB::table('tickets')->whereNull('description')->update(['description' => '']);

        Schema::table('tickets', function (Blueprint $table): void {
            $table->string('name')->nullable(false)->change();
            $table->text('description')->nullable(false)->change();
        });
    }
};
