<?php

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

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

        Schema::create('va_wards', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('business_id');
            $table->unsignedInteger('location_id')->nullable();
            $table->string('name', 100);
            $table->string('code', 30)->nullable();
            $table->enum('type', ['cage', 'kennel', 'run', 'icu', 'ward', 'isolation'])->default('cage');
            $table->unsignedSmallInteger('capacity')->default(1);
            $table->text('notes')->nullable();
            $table->enum('status', ['active', 'inactive'])->default('active');
            $table->timestamps();

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

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