<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddAllowSklDownloadToGraduationSettings extends Migration
{
    public function up()
    {
        // Menambahkan kolom allow_skl_download yang sebelumnya hanya ada
        // melalui SQL manual (graduation_add_skl_toggle.sql)
        if (!$this->db->fieldExists('allow_skl_download', 'graduation_settings')) {
            $this->forge->addColumn('graduation_settings', [
                'allow_skl_download' => [
                    'type'       => 'TINYINT',
                    'constraint' => 1,
                    'null'       => false,
                    'default'    => 0,
                    'after'      => 'is_active',
                ],
            ]);
        }
    }

    public function down()
    {
        if ($this->db->fieldExists('allow_skl_download', 'graduation_settings')) {
            $this->forge->dropColumn('graduation_settings', 'allow_skl_download');
        }
    }
}
