From d4391bd5eca3fcf9c750c845fd3c7333205c7e3b Mon Sep 17 00:00:00 2001 From: Beth Parker Date: Mon, 7 Feb 2022 18:39:20 -0600 Subject: [PATCH] Set up ingredients as separate table from recipe_ingredient - will allow for expansion into inventory tracking --- ..._02_08_001430_create_ingredients_table.php | 6 --- ..._003527_create_recipe_ingredient_table.php | 40 +++++++++++++++++++ 2 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 database/migrations/2022_02_08_003527_create_recipe_ingredient_table.php diff --git a/database/migrations/2022_02_08_001430_create_ingredients_table.php b/database/migrations/2022_02_08_001430_create_ingredients_table.php index 4272a33..2f901b0 100644 --- a/database/migrations/2022_02_08_001430_create_ingredients_table.php +++ b/database/migrations/2022_02_08_001430_create_ingredients_table.php @@ -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'); }); } diff --git a/database/migrations/2022_02_08_003527_create_recipe_ingredient_table.php b/database/migrations/2022_02_08_003527_create_recipe_ingredient_table.php new file mode 100644 index 0000000..c499f4d --- /dev/null +++ b/database/migrations/2022_02_08_003527_create_recipe_ingredient_table.php @@ -0,0 +1,40 @@ +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'); + } +}