<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

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

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

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