<?php

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

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

        Schema::create('clc_medical_conditions', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('business_id')->nullable();
            $table->string('name', 150);
            $table->string('category', 100)->nullable();
            $table->text('description')->nullable();
            $table->string('icd_code', 20)->nullable();
            $table->boolean('is_chronic')->default(false);
            $table->enum('status', ['active', 'inactive'])->default('active');
            $table->timestamps();

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

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