<?php

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

class AddEmailConfirmedToVcPetOwnerDetails extends Migration
{
    public function up()
    {
        if (Schema::hasTable('vc_pet_owner_details') && !Schema::hasColumn('vc_pet_owner_details', 'email_confirmed')) {
            Schema::table('vc_pet_owner_details', function (Blueprint $table) {
                $table->boolean('email_confirmed')->default(false)->after('notes')
                      ->comment('Owner has confirmed email — vaccine reminder emails will only be sent to confirmed addresses');
            });
        }
    }

    public function down()
    {
        if (Schema::hasColumn('vc_pet_owner_details', 'email_confirmed')) {
            Schema::table('vc_pet_owner_details', function (Blueprint $table) {
                $table->dropColumn('email_confirmed');
            });
        }
    }
}
