<?php

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

class CreateVcAppointmentStatusLogsTable extends Migration
{
    public function up()
    {
        if (!Schema::hasTable('vc_appointment_status_logs')) {
            Schema::create('vc_appointment_status_logs', function (Blueprint $table) {
                $table->increments('id');
                $table->unsignedInteger('business_id')->index();
                $table->unsignedInteger('appointment_id')->index();
                $table->string('from_status', 30)->nullable();
                $table->string('to_status', 30);
                $table->unsignedInteger('changed_by')->nullable();
                $table->timestamp('changed_at')->useCurrent();
                $table->timestamps();
            });
        }
    }

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