<?php

namespace App\Database\Migrations\Master;

use CodeIgniter\Database\Migration;

class Kelas extends Migration
{
    public function up()
    {
        $fields = [
            'id'   => ['type' => 'int', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
            'nama' => ['type' => 'varchar', 'constraint' => 255],
            'kode' => ['type' => 'varchar', 'constraint' => 255],
            'is_alumni' => ['type' => 'enum', 'constraint' => ['0', '1'], 'default' => '0'],
        ];
        $this->forge->addField($fields);
        $this->forge->addKey('id', true);
        $this->forge->addUniqueKey('kode');
        $this->forge->createTable('m_kelas', true);
    }

    public function down()
    {
        // drop constraints first to prevent errors
        if ($this->db->DBDriver != 'SQLite3') {
        }
        $this->forge->dropTable('m_kelas', true);
    }
}
