<?php

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

class UpdateEmailHashTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('table_user_email_hash', function (Blueprint $table) {
            $table->dropColumn('hash');

            $table->unique('token');
        });

        Schema::rename('table_user_email_hash', 'table_user_email_token');
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('table_user_email_hash', function (Blueprint $table) {
            $table->string('hash');
            $table->index('hash');

            $table->dropUnique('token');
        });

        Schema::rename('table_user_email_token', 'table_user_email_hash');
    }
}
