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'); + } +}