<?php

/*
 * Copyright (c) 2018 Earworks.
 * Codeigniter Project Template Modification
 * Please contact our email for more information :
 *  contact@earworks.co.id
 */
defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * Description of Migration_Add_users
 *
 * @author Fajar Dwi Rianto <fajar@earworks.co.id>
 * @since 1.0
 */
class Migration_Add_users extends CI_Migration {

    public function up() {
        echo "Start Users Table Migration \n";
        $this->dbforge->add_field(array(
            'userid' => array(
                'type' => 'INT',
                'constraint' => 11,
                'unsigned' => TRUE,
                'auto_increment' => TRUE
            ),
            'username' => array(
                'type' => 'VARCHAR',
                'constraint' => '255',
            ),
            'userpassword' => array(
                'type' => 'VARCHAR',
                'constraint' => '255'
            ),
            'userauth' => array(
                'type' => 'VARCHAR',
                'constraint' => '255',
                'null' => true,
            ),
            'usercode' => array(
                'type' => 'VARCHAR',
                'constraint' => '255',
                'null' => true,
            ),
            'useremail' => array(
                'type' => 'VARCHAR',
                'constraint' => '255',
                'null' => true,
            ),
            'userstatus' => array(
                'type' => 'INT',
                'constraint' => '1',
                'default' => 0
            ),
            'created' => array(
                'type' => 'INT',
                'constraint' => 11,
                'null' => true
            ),
            'modified' => array(
                'type' => 'INT',
                'constraint' => 11,
                'null' => true
            )
        ));
        $this->dbforge->add_key('userid', TRUE);
        if ($this->dbforge->create_table('users')) {
            echo "Status : Success \n";
        } else {
            echo "Status : FAILED \n";
        }
    }

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

}
