<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddRulesAndChairmanToExamEvents extends Migration
{
    public function up()
    {
        if ($this->db->fieldExists('chairman_name', 'exam_events')) return;
        $fields = [
            'proctor_rules' => [
                'type' => 'TEXT',
                'null' => true,
            ],
            'student_rules' => [
                'type' => 'TEXT',
                'null' => true,
            ],
            'chairman_name' => [
                'type'       => 'VARCHAR',
                'constraint' => 150,
                'null'       => true,
            ],
            'chairman_nip' => [
                'type'       => 'VARCHAR',
                'constraint' => 50,
                'null'       => true,
            ],
        ];
        $this->forge->addColumn('exam_events', $fields);
    }

    public function down()
    {
        $this->forge->dropColumn('exam_events', 'proctor_rules');
        $this->forge->dropColumn('exam_events', 'student_rules');
        $this->forge->dropColumn('exam_events', 'chairman_name');
        $this->forge->dropColumn('exam_events', 'chairman_nip');
    }
}
