<?php

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

class AddCategoryToClcVaccineTypes extends Migration
{
    public function up()
    {
        if (Schema::hasTable('clc_vaccine_types') && !Schema::hasColumn('clc_vaccine_types', 'category')) {
            Schema::table('clc_vaccine_types', function (Blueprint $table) {
                $table->enum('category', [
                    'core_vaccine',
                    'non_core_vaccine',
                    'spot_on',
                    'deworming',
                    'oral',
                    'nasal',
                    'topical',
                    'preventive',
                    'other',
                ])->default('core_vaccine')->after('manufacturer');
            });
        }
    }

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