<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddExternalParentEmailToEventCharges extends Migration
{
    public function up()
    {
        $fields = [
            'external_parent_email' => [
                'type' => 'VARCHAR',
                'constraint' => 254,
                'null' => true,
                'after' => 'external_parent_phone',
            ],
        ];

        if (! $this->db->fieldExists('external_parent_email', 'event_charges')) {
            $this->forge->addColumn('event_charges', $fields);
        }
    }

    public function down()
    {
        if ($this->db->fieldExists('external_parent_email', 'event_charges')) {
            $this->forge->dropColumn('event_charges', 'external_parent_email');
        }
    }
}

