<?php

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

class CreateUsers extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
        Schema::create('users', function (Blueprint $table) {
            // General
            $table->bigIncrements('id');
            $table->string('email', 255)->unique();
            $table->string('password', 255)->nullable();
            $table->nullableTimestamps();
            $table->datetime('last_login')->nullable();
            $table->datetime('email_verified_date')->nullable();
            $table->string('email_confirm_token', 255)->nullable();
            $table->datetime('recover_date')->nullable();
            $table->string('recover_token', 255)->nullable();
            $table->string('state', 20)->default('active');
            $table->string('name', 100);
            $table->bigInteger('city_id')->nullable()->unsigned();

            $table->foreign('city_id')
                ->references('id')
                ->on('cities')
                ->onDelete('set null');
        });
	}
	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
        Schema::dropIfExists('users');
	}

}
