<?php

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

class CreateVcAppointmentReasonsTable extends Migration
{
    public function up()
    {
        if (!Schema::hasTable('vc_appointment_reasons')) {
            Schema::create('vc_appointment_reasons', function (Blueprint $table) {
                $table->increments('id');
                $table->unsignedInteger('business_id');
                $table->string('name', 150);
                $table->enum('status', ['active', 'inactive'])->default('active');
                $table->unsignedSmallInteger('sort_order')->default(0);
                $table->timestamps();

                $table->foreign('business_id')->references('id')->on('business')->onDelete('cascade');
                $table->index(['business_id', 'status']);
            });
        }
    }

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