diff --git a/database/migrations/2021_07_07_154816_add_spell_id_to_recipes.php b/database/migrations/2021_07_07_154816_add_spell_id_to_recipes.php new file mode 100644 index 0000000..4518c24 --- /dev/null +++ b/database/migrations/2021_07_07_154816_add_spell_id_to_recipes.php @@ -0,0 +1,30 @@ +foreignId('spell_id')->after('item_id')->nullable()->constrained(); + + // Drop foreign key because we can't drop unique otherwise. + $table->dropForeign(['item_id']); + $table->dropForeign(['profession_id']); + $table->dropUnique(['profession_id', 'item_id']); + + // Add them again and the new unique compound key. + $table->foreign('item_id')->references('id')->on('items')->constrained(); + $table->foreign('profession_id')->references('id')->on('professions')->constrained(); + $table->unique(['profession_id', 'item_id', 'spell_id']); + }); + } +}