<?php

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

return new class extends Migration
{
    public function up(): void
    {
        if (! Schema::hasTable('reports') || ! Schema::hasColumn('reports', 'target_type')) {
            return;
        }

        if (DB::getDriverName() === 'mysql') {
            DB::statement("ALTER TABLE reports MODIFY target_type ENUM('message','conversation','user','story') NOT NULL");
        }
    }

    public function down(): void
    {
        if (! Schema::hasTable('reports') || ! Schema::hasColumn('reports', 'target_type')) {
            return;
        }

        if (DB::getDriverName() === 'mysql') {
            DB::statement("ALTER TABLE reports MODIFY target_type ENUM('message','conversation','user') NOT NULL");
        }
    }
};
