<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CreateTahunAkademikTable extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'id' => [
                'type'           => 'INT',
                'constraint'     => 11,
                'unsigned'       => true,
                'auto_increment' => true,
            ],
            'kode_ta' => [
                'type'       => 'VARCHAR',
                'constraint' => '10',
                'unique'     => true,
                'comment'    => 'Example: 20231 for 2023/2024 Ganjil',
            ],
            'nama_ta' => [
                'type'       => 'VARCHAR',
                'constraint' => '100',
            ],
            'status' => [
                'type'       => 'ENUM',
                'constraint' => ['Aktif', 'Tidak Aktif'],
                'default'    => 'Tidak Aktif',
            ],
            'id_semester_pddikti' => [
                'type'       => 'CHAR',
                'constraint' => 36,
                'null'       => true,
                'comment'    => 'ID Semester dari Neo Feeder',
            ],
            'created_at' => [
                'type' => 'DATETIME',
                'null' => true,
            ],
            'updated_at' => [
                'type' => 'DATETIME',
                'null' => true,
            ],
        ]);
        $this->forge->addKey('id', true);
        $this->forge->createTable('tahun_akademik');
    }

    public function down()
    {
        $this->forge->dropTable('tahun_akademik');
    }
}
