<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddWaiverSignedToEventCharges extends Migration
{
    public function up()
    {
        $fields = [
            'waiver_signed' => [
                'type' => 'TINYINT',
                'constraint' => 1,
                'default' => 0,
                'after' => 'charged',
            ],
        ];

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

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