<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('clinical_histories', function (Blueprint $table) {
            $table->string('history_number', 50)->nullable()->after('customer_id');
            $table->date('opening_date')->nullable()->after('history_number');
            $table->enum('status', ['active', 'closed', 'archived'])->default('active')->after('opening_date');

            $table->unique(['company_id', 'history_number']);
        });
    }

    public function down(): void
    {
        Schema::table('clinical_histories', function (Blueprint $table) {
            $table->dropUnique(['company_id', 'history_number']);
            $table->dropColumn(['history_number', 'opening_date', 'status']);
        });
    }
};
