<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddKomisiProdukToHargaMarketplace extends Migration
{
    public function up(): void
    {
        // Cek dulu pakai try-catch agar aman jika kolom sudah ada
        try {
            $this->db->query("ALTER TABLE `tb_harga_marketplace` ADD COLUMN `komisi_produk` DECIMAL(5,2) NOT NULL DEFAULT 0 AFTER `harga_marketplace`");
        } catch (\Exception $e) {
            // kolom sudah ada, skip
        }
    }

    public function down(): void
    {
        try {
            $this->db->query("ALTER TABLE `tb_harga_marketplace` DROP COLUMN `komisi_produk`");
        } catch (\Exception $e) {}
    }
}