<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        // Update old statuses to 'approved'
        DB::table('purchase_orders')
            ->whereIn('status', ['processing', 'shipping', 'confirming'])
            ->update(['status' => 'approved']);
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        // Cannot easily reverse without knowing original status, 
        // but typically we can revert 'approved' back to 'processing' as a safeguard if needed,
        // or just leave it since 'approved' is broader.
        // For strict reversal, we might try to map back, but effectively this is a one-way consolidation.
        // We will leave it as is for down/safe side.
    }
};
