<?php namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class Create_users extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'id' => ['type'=>'BIGINT','unsigned'=>true,'auto_increment'=>true],
            'name'=>['type'=>'VARCHAR','constraint'=>150],
            'email'=>['type'=>'VARCHAR','constraint'=>150,'null'=>true],
            'phone'=>['type'=>'VARCHAR','constraint'=>50,'null'=>true],
            'password'=>['type'=>'VARCHAR','constraint'=>255,'null'=>true],
            'role'=>['type'=>'VARCHAR','constraint'=>30,'default'=>'user'],
            'created_at'=>['type'=>'DATETIME','null'=>true],
            'updated_at'=>['type'=>'DATETIME','null'=>true],
        ]);
        $this->forge->addKey('id', true);
        $this->forge->createTable('users');
    }

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