<?php

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

class AddWaivedColumnsToClcVaccinations extends Migration
{
    public function up()
    {
        Schema::table('clc_vaccinations', function (Blueprint $table) {
            if (!Schema::hasColumn('clc_vaccinations', 'waived_at')) {
                $table->timestamp('waived_at')->nullable()->after('reminder_sent');
            }
            if (!Schema::hasColumn('clc_vaccinations', 'waived_reason')) {
                $table->string('waived_reason')->nullable()->after('waived_at');
            }
            if (!Schema::hasColumn('clc_vaccinations', 'waived_note')) {
                $table->string('waived_note')->nullable()->after('waived_reason');
            }
            if (!Schema::hasColumn('clc_vaccinations', 'waived_by')) {
                $table->unsignedBigInteger('waived_by')->nullable()->after('waived_note');
            }
        });
    }

    public function down()
    {
        Schema::table('clc_vaccinations', function (Blueprint $table) {
            $table->dropColumn(['waived_at', 'waived_reason', 'waived_note', 'waived_by']);
        });
    }
}
