<?php

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

// ══════════════════════════════════════════════════════════════════
//  InPractice — Migration
//  File: 2026_05_30_000001_expand_experience_level_enum.php
//  Location: database/migrations/
//
//  Expands the experience_level enum on the users table to include
//  the new experience bands requested.
// ══════════════════════════════════════════════════════════════════

return new class extends Migration
{
    public function up(): void
    {
        // MySQL requires ALTER COLUMN with full new enum definition
        DB::statement("
            ALTER TABLE users
            MODIFY COLUMN experience_level ENUM(
                'student',
                'fresh',
                'junior',
                'mid',
                'senior',
                'senior_10',
                'senior_15',
                'senior_20',
                'veteran'
            ) NOT NULL DEFAULT 'fresh'
        ");
    }

    public function down(): void
    {
        // Revert to original 5 values
        // Note: any rows with new values will be set to 'senior' before reverting
        DB::statement("UPDATE users SET experience_level = 'senior'
            WHERE experience_level IN ('senior_10','senior_15','senior_20','veteran')");

        DB::statement("
            ALTER TABLE users
            MODIFY COLUMN experience_level ENUM(
                'student',
                'fresh',
                'junior',
                'mid',
                'senior'
            ) NOT NULL DEFAULT 'fresh'
        ");
    }
};
