<?php

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

class CreateClcVaccineTypesTable extends Migration
{
    public function up()
    {
        if (Schema::hasTable('clc_vaccine_types')) return;

        Schema::create('clc_vaccine_types', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('business_id')->nullable();
            $table->string('name', 150);
            $table->string('manufacturer', 100)->nullable();
            $table->json('species_target')->nullable();
            $table->text('description')->nullable();
            $table->unsignedSmallInteger('valid_for_months')->default(12);
            $table->enum('status', ['active', 'inactive'])->default('active');
            $table->timestamps();

            $table->index(['business_id', 'status']);
        });
    }

    public function down()
    {
        Schema::dropIfExists('clc_vaccine_types');
    }
}
