<?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
	{
		Schema::table('ai_keywords', function (Blueprint $table) {
			// First update existing records to null
			\DB::table('ai_keywords')->update(['priority' => null]);
			
			// Then modify the column to be nullable
			$table->enum('priority', ['high', 'medium', 'low'])->nullable()->change();
		});
	}
	
	/**
	 * Reverse the migrations.
	 */
	public function down(): void
	{
		Schema::table('ai_keywords', function (Blueprint $table) {
			$table->enum('priority', ['high', 'medium', 'low'])->default('medium')->change();
		});
	}
};