<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddEventPaymentRefToEventCharges extends Migration
{
    public function up()
    {
        $fields = [
            'event_payment_id' => [
                'type' => 'INT',
                'constraint' => 11,
                'unsigned' => true,
                'null' => true,
                'after' => 'class_section_id',
            ],
        ];

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

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