File: /home/imensosw/.trash/database/migrations/2021_02_05_093405_add_foreign_keys_to_profiles_table.php
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddForeignKeysToProfilesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('profiles', function (Blueprint $table) {
$table->foreign('gender_id', 'profiles_ibfk_1')->references('id')->on('genders')->onUpdate('RESTRICT')->onDelete('RESTRICT');
$table->foreign('user_id', 'profiles_ibfk_2')->references('id')->on('users')->onUpdate('RESTRICT')->onDelete('RESTRICT');
$table->foreign('nationality_country_id', 'profiles_ibfk_3')->references('id')->on('countrys')->onUpdate('RESTRICT')->onDelete('RESTRICT');
$table->foreign('residence_country_id', 'profiles_ibfk_4')->references('id')->on('countrys')->onUpdate('RESTRICT')->onDelete('RESTRICT');
$table->foreign('translator_status_id', 'profiles_ibfk_5')->references('id')->on('translator_status')->onUpdate('RESTRICT')->onDelete('RESTRICT');
$table->foreign('profile_status_id', 'profiles_ibfk_6')->references('id')->on('status')->onUpdate('RESTRICT')->onDelete('RESTRICT');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('profiles', function (Blueprint $table) {
$table->dropForeign('profiles_ibfk_1');
$table->dropForeign('profiles_ibfk_2');
$table->dropForeign('profiles_ibfk_3');
$table->dropForeign('profiles_ibfk_4');
$table->dropForeign('profiles_ibfk_5');
$table->dropForeign('profiles_ibfk_6');
});
}
}