<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddStatusPembayaranToPembelianBahan extends Migration
{
    public function up(): void
    {
        $this->db->query("
            ALTER TABLE `tb_pembelian_bahan`
            ADD COLUMN `status_pembayaran` ENUM('Lunas','Belum Lunas')
                NOT NULL DEFAULT 'Lunas'
                AFTER `total_pembelian_bahan`,
            ADD COLUMN `tanggal_jatuh_tempo` DATE NULL DEFAULT NULL
                AFTER `status_pembayaran`,
            ADD COLUMN `tanggal_lunas` DATE NULL DEFAULT NULL
                AFTER `tanggal_jatuh_tempo`
        ");
    }

    public function down(): void
    {
        $this->db->query("
            ALTER TABLE `tb_pembelian_bahan`
            DROP COLUMN `status_pembayaran`,
            DROP COLUMN `tanggal_jatuh_tempo`,
            DROP COLUMN `tanggal_lunas`
        ");
    }
}