<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUserTable extends Migration
{

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user', function (Blueprint $table) {
            $table->increments('oid');
            $table->string('userid', 255);
            $table->string('firstname', 50)->nullable();
            $table->string('lastname', 50)->nullable();
            $table->string('username', 50)->nullable();
            $table->string('password', 256)->nullable();
            $table->string('mobile', 50)->nullable();
            $table->string('picture', 255)->nullable();
            $table->boolean('is_employee')->nullable();

            $table->index([ 'is_employee' ]);
            $table->unique('username');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        DB::statement('SET FOREIGN_KEY_CHECKS = 0');
        Schema::dropIfExists('user');
        DB::statement('SET FOREIGN_KEY_CHECKS = 1');
    }
}
