<?php

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

class AddForeignKeysToLangAppNavDrawersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('lang_app_nav_drawers', function (Blueprint $table) {
            //
            $table->integer('merchant_id')->unsigned()->change();
            $table->foreign('merchant_id')->references('id')->on('merchants')->onUpdate('RESTRICT')->onDelete('CASCADE');

            $table->integer('merchant_nav_drawer_id')->unsigned()->nullable()->change();
            $table->foreign('merchant_nav_drawer_id')->references('id')->on('merchant_nav_drawers')->onUpdate('RESTRICT')->onDelete('CASCADE');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('lang_app_nav_drawers', function (Blueprint $table) {
            //
            $table->dropForeign('merchant_id');
            $table->dropForeign('merchant_nav_drawer_id');
        });
    }
}
