<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddKibAndColumns extends Migration
{
    public function up()
    {
        $this->forge->addColumn('barang', [
            'kib' => [
                'type' => 'VARCHAR',
                'constraint' => 100,
                'null' => true,
                'after' => 'id'
            ]
        ]);

        $this->forge->addColumn('buku', [
            'kib' => [
                'type' => 'VARCHAR',
                'constraint' => 100,
                'null' => true,
                'after' => 'id'
            ],
            'kode_barang' => [
                'type' => 'VARCHAR',
                'constraint' => 100,
                'null' => true,
                'after' => 'kib'
            ],
            'jenis_bacaan' => [
                'type' => 'VARCHAR',
                'constraint' => 255,
                'null' => true,
                'after' => 'judul'
            ]
        ]);
    }

    public function down()
    {
        $this->forge->dropColumn('barang', 'kib');
        $this->forge->dropColumn('buku', ['kib', 'kode_barang', 'jenis_bacaan']);
    }
}
