<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddCatatanToDokumen extends Migration
{
    public function up()
    {
        $fields = [];
        if (!$this->db->fieldExists('status_verifikasi', 'dokumen')) {
            $fields['status_verifikasi'] = [
                'type' => 'VARCHAR',
                'constraint' => 50,
                'default' => 'PENDING',
                'null' => true,
            ];
        }

        if (!$this->db->fieldExists('catatan', 'dokumen')) {
            $fields['catatan'] = [
                'type' => 'TEXT',
                'null' => true,
            ];
        }

        if (!empty($fields)) {
            $this->forge->addColumn('dokumen', $fields);
        }
    }

    public function down()
    {
        $this->forge->dropColumn('dokumen', ['status_verifikasi', 'catatan']);
    }
}
