<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Migration_Add_absen extends CI_Migration {

    public function up() {
        $this->dbforge->add_field([
            'id' => [
                'type' => 'BIGINT',
                'constraint' => 20,
                'unsigned' => true,
                'auto_increment' => true
            ],
            'nama' => [
                'type' => 'VARCHAR',
                'constraint' => 50,
            ],
            'slug' => [
                'type' => 'VARCHAR',
                'constraint' => 50,
            ],
            'keterangan' => [
                'type' => 'TEXT',
                'null' => true
            ],
            'syarat' => [
                'type' => 'TEXT',
                'null' => true
            ],
            'tipe' => [
                'type' => 'SMALLINT',
                'constraint' => 1,
                'null' => true,
                'default' => 1,
                'comment' => '1 = ACARA' // DEFINE LATER
            ],
            'status' => [
                'type' => 'SMALLINT',
                'constraint' => 1,
                'null' => true,
                'default' => 1,
                'comment' => '1 = ACTIVE, 2 = BANNED'
            ],
            'active' => [
                'type' => 'SMALLINT',
                'constraint' => 1,
                'null' => true,
                'default' => 1,
                'comment' => '0 = INACTIVE, 1 = ACTIVE'
            ],
            'created_at' => [
                'type' => 'timestamp',
                'null' => true
            ],
            'updated_at' => [
                'type' => 'timestamp',
                'null' => true
            ],
            'deleted_at' => [
                'type' => 'timestamp',
                'null' => true
            ],
            'created_by' => [
                'type' => 'BIGINT',
                'constraint' => 20,
                'unsigned' => true,
                'null' => true
            ],
            'updated_by' => [
                'type' => 'BIGINT',
                'constraint' => 20,
                'unsigned' => true,
                'null' => true
            ],
            'deleted_by' => [
                'type' => 'BIGINT',
                'constraint' => 20,
                'unsigned' => true,
                'null' => true
            ],
        ]);
        $this->dbforge->add_key('id', true);
        $this->dbforge->create_table('absen');
    }

    //--------------------------------------------------------------------

    public function down() {
        $this->dbforge->drop_table('absen');
    }

}
