<?php

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

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if(!Schema::hasTable('users')) {
            Schema::create('users', function (Blueprint $table) {
                $table->bigIncrements('id');
                $table->char('uuid', 36);
                $table->string('first_name')->nullable();
                $table->string('last_name')->nullable();
                $table->string('email')->unique();
                $table->string('avatar_type')->default('gravatar');
                $table->string('avatar_location')->nullable();
                $table->string('password')->nullable();
                $table->timestamp('password_changed_at')->nullable();
                $table->unsignedTinyInteger('active')->default(1);
                $table->string('confirmation_code')->nullable();
                $table->boolean('confirmed')->default(0);
                $table->string('timezone')->nullable();
                $table->timestamp('last_login_at')->nullable();
                $table->string('last_login_ip')->nullable();
                $table->boolean('to_be_logged_out')->default(0);
                $table->rememberToken();
                $table->timestamps();
                $table->softDeletes();
                $table->integer('prefix_lookup_id')->nullable();
                $table->integer('institution_lookup_id')->nullable();
                $table->integer('position_lookup_id')->nullable();
                $table->string('research_focus_lookup_ids', 45)->nullable();
                $table->string('stripe_id')->nullable()->index();
                $table->string('card_brand')->nullable();
                $table->string('card_last_four', 4)->nullable();
                $table->timestamp('trial_ends_at')->nullable();
                $table->string('first_login', 45)->nullable()->default('true');
                $table->string('phone', 45)->nullable();
                $table->string('public', 45)->nullable();
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
