<?php

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

class CreateVcAppointmentDocumentsTable extends Migration
{
    public function up()
    {
        if (!Schema::hasTable('vc_appointment_documents')) {
            Schema::create('vc_appointment_documents', function (Blueprint $table) {
                $table->increments('id');
                $table->unsignedInteger('business_id');
                $table->unsignedInteger('appointment_id');
                $table->unsignedInteger('user_id')->nullable();
                $table->string('document_name');
                $table->enum('document_type', ['lab_report','xray','prescription','consent_form','discharge_summary','other'])->default('other');
                $table->text('description')->nullable();
                $table->string('file_name');
                $table->string('file_path', 500);
                $table->unsignedBigInteger('file_size')->nullable();
                $table->string('mime_type', 100)->nullable();
                $table->timestamps();
                $table->foreign('appointment_id')->references('id')->on('vc_appointments')->onDelete('cascade');
            });
        }
    }

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