<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddDetailFieldsToPengajuan extends Migration
{
    public function up()
    {
        $fields = [
            'tempat_lahir'         => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true],
            'tanggal_lahir'        => ['type' => 'DATE', 'null' => true],
            'pendidikan_lama'      => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true],
            'tahun_lulus'          => ['type' => 'INT', 'constraint' => 4, 'null' => true],
            'gelar_depan'          => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
            'gelar_belakang'       => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
            'unor'                 => ['type' => 'VARCHAR', 'constraint' => 150, 'null' => true],
            'unit_kerja_induk'     => ['type' => 'VARCHAR', 'constraint' => 150, 'null' => true],
            'jabatan_lama'         => ['type' => 'VARCHAR', 'constraint' => 150, 'null' => true],
            'jabatan_baru'         => ['type' => 'VARCHAR', 'constraint' => 150, 'null' => true],
            'lokasi_kerja'         => ['type' => 'VARCHAR', 'constraint' => 150, 'null' => true],
            'instansi_kerja'       => ['type' => 'VARCHAR', 'constraint' => 150, 'null' => true],
            'tahun_gaji'           => ['type' => 'YEAR', 'null' => true],
            'gol_awal'             => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
            'tmt_golongan_lama'    => ['type' => 'DATE', 'null' => true],
            'mkt_lama'             => ['type' => 'INT', 'constraint' => 5, 'null' => true],
            'mkb_lama'             => ['type' => 'INT', 'constraint' => 5, 'null' => true],
            'gajipokok_lama'       => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
            'mkt_baru'             => ['type' => 'INT', 'constraint' => 5, 'null' => true],
            'mkb_baru'             => ['type' => 'INT', 'constraint' => 5, 'null' => true],
            'gajipokok_baru'       => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
            'tmt_jabatan_lama'     => ['type' => 'DATE', 'null' => true],
            'gol_baru'             => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
            'tmt_gol_baru'         => ['type' => 'DATE', 'null' => true],
            'atasan_nama'          => ['type' => 'VARCHAR', 'constraint' => 150, 'null' => true],
            'atasan_nip'           => ['type' => 'VARCHAR', 'constraint' => 20, 'null' => true],
            'atasan_jabatan'       => ['type' => 'VARCHAR', 'constraint' => 150, 'null' => true],
            'atasan_gol'           => ['type' => 'VARCHAR', 'constraint' => 20, 'null' => true],
            'masa_kerja_tahun'     => ['type' => 'INT', 'constraint' => 5, 'null' => true],
            'masa_kerja_bulan'     => ['type' => 'INT', 'constraint' => 5, 'null' => true],
            'keterangan_kp'        => ['type' => 'TEXT', 'null' => true],
        ];
        $this->forge->addColumn('pengajuan', $fields);
    }

    public function down()
    {
        $this->forge->dropColumn('pengajuan', [
            'tempat_lahir', 'tanggal_lahir', 'pendidikan_lama', 'tahun_lulus', 'gelar_depan', 'gelar_belakang',
            'unor', 'unit_kerja_induk', 'jabatan_lama', 'jabatan_baru', 'lokasi_kerja', 'instansi_kerja',
            'tahun_gaji', 'gol_awal', 'tmt_golongan_lama', 'mkt_lama', 'mkb_lama', 'gajipokok_lama',
            'mkt_baru', 'mkb_baru', 'gajipokok_baru', 'tmt_jabatan_lama', 'gol_baru', 'tmt_gol_baru',
            'atasan_nama', 'atasan_nip', 'atasan_jabatan', 'atasan_gol', 'masa_kerja_tahun', 'masa_kerja_bulan',
            'keterangan_kp'
        ]);
    }
}
