<?php

use App\Enums\PracticeSetting;
use App\Enums\ProfessionalRole;
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
    {
        Schema::table('user_profiles', function (Blueprint $table) {
            $table->dropColumn(['status', 'practice', 'practice_type', 'practice_place']);
            $table->dropColumn('birthdate');
        });

        Schema::table('user_profiles', function (Blueprint $table) {
            $table->integer('birth_year')->nullable();
            $table->enum('professional_role', array_column(ProfessionalRole::cases(), 'value'))->nullable();
            $table->enum('practice_setting', array_column(PracticeSetting::cases(), 'value'))->nullable();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('user_profiles', function (Blueprint $table) {
            $table->dropColumn(['birth_year', 'professional_role', 'practice_setting']);
        });

        Schema::table('user_profiles', function (Blueprint $table) {
            $table->date('birthdate')->nullable();
            $table->string('practice_place');
            $table->enum('practice_type', ['private', 'public'])->nullable();
            $table->enum('practice', ['gastrointestinal_endoscopist', 'endoscopic_surgeon', 'nurse'])->nullable();
            $table->enum('status', ['fellow', 'thesus_less_two_years', 'thesus_more_two_years'])->nullable();
        });
    }
};
