<?php

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

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

        Schema::create('va_admission_care_plan', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('admission_id');
            $table->unsignedInteger('care_task_type_id');
            $table->unsignedTinyInteger('times_per_day')->default(1);
            // optional specific clock times, e.g. ["08:00","14:00","20:00"]
            $table->json('schedule_times')->nullable();
            $table->string('instructions', 500)->nullable();
            $table->boolean('active')->default(true);
            $table->timestamps();

            $table->index('admission_id');
        });
    }

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