<?php

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

class AddTakenStatusToVcVaccinations extends Migration
{
    public function up()
    {
        if (Schema::hasTable('vc_vaccinations') && !Schema::hasColumn('vc_vaccinations', 'taken_status')) {
            Schema::table('vc_vaccinations', function (Blueprint $table) {
                $table->enum('taken_status', ['taken_in', 'taken_out', 'not_taken'])
                      ->nullable()
                      ->after('status')
                      ->comment('taken_in=at clinic, taken_out=external, not_taken=scheduled/not yet given');
            });
        }
    }

    public function down()
    {
        if (Schema::hasColumn('vc_vaccinations', 'taken_status')) {
            Schema::table('vc_vaccinations', function (Blueprint $table) {
                $table->dropColumn('taken_status');
            });
        }
    }
}
