<?php

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

class CreateCoreUserTable extends Migration
{
    protected $tableName = 'core_user';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create($this->tableName, function (Blueprint $table) {
            $table->increments('user_id');
            $table->string('username')->nullable()->unique();
            $table->string('email')->unique();
            $table->string('first')->default(null);
            $table->string('last')->default(null);
            $table->string('password')->nullable()->default(null)->collate('utf8_bin');
            $table->string('password_salt')->nullable()->default(null)->collate('utf8_bin');
            $table->unsignedTinyInteger('status')->default(0);
            $table->boolean('internal')->default(0);
            $table->rememberToken();
            $table->timestamp('last_login_at')->nullable()->default(null);
            $table->timestamps();
        });

        // note: it@brightspot.email should still be id #1 by seeder and for Helix
        DB::statement("ALTER TABLE core_user AUTO_INCREMENT = 100");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists($this->tableName);
    }
}
