<?php

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

class AddPartialStatusToNstPrepareProducts extends Migration
{
    public function up()
    {
        // Add 'partial' to the status ENUM
        DB::statement("ALTER TABLE nst_prepare_products
            MODIFY COLUMN status ENUM('prepare', 'receive', 'partial', 'complete')
            NOT NULL DEFAULT 'prepare'");
    }

    public function down()
    {
        // Before removing 'partial', update any rows that have it to 'receive'
        DB::statement("UPDATE nst_prepare_products SET status = 'receive' WHERE status = 'partial'");

        // Remove 'partial' from the ENUM
        DB::statement("ALTER TABLE nst_prepare_products
            MODIFY COLUMN status ENUM('prepare', 'receive', 'complete')
            NOT NULL DEFAULT 'prepare'");
    }
}
