<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CreateRefWilayahTable extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'id_wilayah' => [
                'type'       => 'VARCHAR',
                'constraint' => '8',
                'null'       => false,
            ],
            'nama_wilayah' => [
                'type'       => 'VARCHAR',
                'constraint' => '255',
                'null'       => false,
            ],
            'id_induk_wilayah' => [
                'type'       => 'VARCHAR',
                'constraint' => '8',
                'null'       => true,
            ],
        ]);
        
        $this->forge->addKey('id_wilayah', true);
        $this->forge->addKey('id_induk_wilayah');
        $this->forge->addKey('nama_wilayah');
        $this->forge->createTable('ref_wilayah');
    }

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