44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
|
<?php
|
||
|
|
||
|
use Illuminate\Support\Facades\Schema;
|
||
|
use Illuminate\Database\Schema\Blueprint;
|
||
|
use Illuminate\Database\Migrations\Migration;
|
||
|
|
||
|
class CreateUsersRecipesTable extends Migration
|
||
|
{
|
||
|
/**
|
||
|
* Run the migrations.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function up()
|
||
|
{
|
||
|
Schema::create('users_recipes', function (Blueprint $table) {
|
||
|
$table->bigIncrements('id');
|
||
|
$table->unsignedInteger('user_id');
|
||
|
$table->unsignedInteger('recipe_id');
|
||
|
$table->foreign('user_id')
|
||
|
->references('id')
|
||
|
->on('users')
|
||
|
->onUpdate('cascade')
|
||
|
->onDelete('cascade');
|
||
|
$table->foreign('recipe_id')
|
||
|
->references('id')
|
||
|
->on('recipes')
|
||
|
->onUpdate('cascade')
|
||
|
->onDelete('cascade');
|
||
|
$table->timestamp('created_at');
|
||
|
});
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Reverse the migrations.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function down()
|
||
|
{
|
||
|
Schema::dropIfExists('users_recipes');
|
||
|
}
|
||
|
}
|