<?php

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

class CreateTravelNationalityRequirementTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::connection('mysql_stern')->create('travel_nationality_requirement', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('travel_country_id')->nullable();
            $table->integer('travel_nationality_id')->nullable();
            $table->text('text')->nullable();

            $table->index('travel_country_id', 'travel_country_id');
            $table->index('travel_nationality_id', 'travel_nationality_id');

            $table->foreign('travel_nationality_id', 'travel_nationality_requirement_ibfk_2')->references('id')->on('travel_nationality')
                ->onDelete('RESTRICT')->onUpdate('RESTRICT');
            $table->foreign('travel_country_id', 'travel_nationality_requirement_ibfk_3')->references('id')->on('travel_country')
                ->onDelete('RESTRICT')->onUpdate('RESTRICT');

        });



    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::connection('mysql_stern')->dropIfExists('travel_nationality_requirement');
    }
}

