<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CreateRuangBaca extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'id' => [
                'type' => 'INT',
                'constraint' => 11,
                'unsigned' => true,
                'auto_increment' => true,
            ],
            'judul' => [
                'type' => 'VARCHAR',
                'constraint' => 200,
            ],
            'penulis' => [
                'type' => 'VARCHAR',
                'constraint' => 100,
            ],
            'kategori' => [
                'type' => 'VARCHAR',
                'constraint' => 50,
            ],
            'jenis' => [
                'type' => 'ENUM',
                'constraint' => ['buku', 'artikel'],
                'default' => 'buku',
            ],
            'file_pdf' => [
                'type' => 'VARCHAR',
                'constraint' => 255,
            ],
            'created_at' => [
                'type' => 'DATETIME',
                'null' => true,
            ],
            'updated_at' => [
                'type' => 'DATETIME',
                'null' => true,
            ],
        ]);

        $this->forge->addKey('id', true);
        $this->forge->createTable('ruang_baca');
    }

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