osb/database/migrations/2017_06_18_104533_add_foreign_keys_to_countries_table.php

36 lines
635 B
PHP
Raw Normal View History

2018-06-18 11:18:34 +00:00
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddForeignKeysToCountriesTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('countries', function(Blueprint $table)
{
$table->foreign('currency_id')->references('id')->on('currencies')->onUpdate('RESTRICT')->onDelete('RESTRICT');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('countries', function(Blueprint $table)
{
$table->dropForeign('countries_currency_id_foreign');
});
}
}