<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddLetterOriginToSchoolSettings extends Migration
{
    public function up()
    {
        if ($this->db->fieldExists('letter_origin', 'school_settings')) return;
        $this->forge->addColumn('school_settings', [
            'letter_origin' => [
                'type'       => 'VARCHAR',
                'constraint' => 200,
                'null'       => true,
                'comment'    => 'Tempat berangkat default untuk SPPD, contoh: MTs Negeri 1 Wonogiri',
                'after'      => 'letter_city',
            ],
            'letter_budget_code' => [
                'type'       => 'VARCHAR',
                'constraint' => 100,
                'null'       => true,
                'comment'    => 'Kode MAK/anggaran default untuk SPPD',
                'after'      => 'letter_origin',
            ],
        ]);
    }

    public function down()
    {
        $this->forge->dropColumn('school_settings', ['letter_origin', 'letter_budget_code']);
    }
}