forked from acearo/base-laravel
Set up ingredients as separate table from recipe_ingredient - will allow for expansion into inventory tracking
This commit is contained in:
parent
a7bbf15408
commit
d4391bd5ec
2 changed files with 40 additions and 6 deletions
|
@ -15,14 +15,8 @@ class CreateIngredientsTable extends Migration
|
|||
{
|
||||
Schema::create('ingredients', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedInteger('recipe_id');
|
||||
$table->string('name');
|
||||
$table->unsignedInteger('quantity');
|
||||
$table->string('measurement');
|
||||
$table->longText('special_notes');
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('recipe_id')->references('id')->on('recipes');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateRecipeIngredientTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('recipe_ingredient', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedInteger('recipe_id');
|
||||
$table->unsignedInteger('ingredient_id');
|
||||
$table->string('name');
|
||||
$table->unsignedInteger('quantity');
|
||||
$table->string('measurement');
|
||||
$table->longText('special_notes');
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('recipe_id')->references('id')->on('recipes');
|
||||
$table->foreign('ingredient_id')->references('id')->on('ingredients');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('recipe_ingredient');
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue