From 9b79d9c756de51b4e0d2e9e7a0032103023f2c7a Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Tue, 3 Oct 2017 23:33:46 -0500 Subject: [PATCH] Delete service variables when the option is deleted. --- ...cadeDeletionWhenServiceOptionIsDeleted.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 database/migrations/2017_10_03_233202_CascadeDeletionWhenServiceOptionIsDeleted.php diff --git a/database/migrations/2017_10_03_233202_CascadeDeletionWhenServiceOptionIsDeleted.php b/database/migrations/2017_10_03_233202_CascadeDeletionWhenServiceOptionIsDeleted.php new file mode 100644 index 000000000..3b19e3d99 --- /dev/null +++ b/database/migrations/2017_10_03_233202_CascadeDeletionWhenServiceOptionIsDeleted.php @@ -0,0 +1,32 @@ +dropForeign(['option_id']); + + $table->foreign('option_id')->references('id')->on('service_options')->onDelete('CASCADE'); + }); + } + + /** + * Reverse the migrations. + */ + public function down() + { + Schema::table('service_variables', function (Blueprint $table) { + $table->dropForeign(['option_id']); + + $table->foreign('option_id')->references('id')->on('service_options'); + }); + } +}