<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class CreateUsersTable extends Migration {
  public function up() {
    $this->forge->addField([
      'id'       => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
      'role_id'  => ['type' => 'TINYINT', 'null' => false],
      'username' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
      'password' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
    ]);
    $this->forge->addKey('id', true);
    $this->forge->createTable('users');
  }

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