<?php

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

class UpdateDevicesTableIndexes extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('devices', function (Blueprint $table) {
            $table->dropUnique('devices_identifier_unique');
            $table->string('fcm_token', 512)->change();
            $table->unique(['user_id', 'identifier', 'fcm_token']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('devices', function (Blueprint $table) {

            $table->dropUnique('devices_user_id_identifier_fcm_token__unique');
            $table->text('fcm_token')->nullable();
            $table->unique('identifier');
        });
    }
}
