From a73e71dd81e18cf890a244db64947a89244191f6 Mon Sep 17 00:00:00 2001 From: Anand Capur Date: Wed, 23 Aug 2017 12:34:34 -0700 Subject: [PATCH] Fix DB migrations to allow rollbacks --- ...2017_08_05_144104_AllowNegativeValuesForOverallocation.php | 4 ++-- ...17_08_05_174811_SetAllocationUnqiueUsingMultipleFields.php | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/database/migrations/2017_08_05_144104_AllowNegativeValuesForOverallocation.php b/database/migrations/2017_08_05_144104_AllowNegativeValuesForOverallocation.php index 260af9a4d..77b7f984c 100644 --- a/database/migrations/2017_08_05_144104_AllowNegativeValuesForOverallocation.php +++ b/database/migrations/2017_08_05_144104_AllowNegativeValuesForOverallocation.php @@ -23,8 +23,8 @@ class AllowNegativeValuesForOverallocation extends Migration public function down() { Schema::table('nodes', function (Blueprint $table) { - $table->mediumInteger('disk_overallocate')->unsigned()->nullable()->change(); - $table->mediumInteger('memory_overallocate')->unsigned()->nullable()->change(); + DB::statement('ALTER TABLE nodes MODIFY disk_overallocate MEDIUMINT UNSIGNED NULL, + MODIFY memory_overallocate MEDIUMINT UNSIGNED NULL'); }); } } diff --git a/database/migrations/2017_08_05_174811_SetAllocationUnqiueUsingMultipleFields.php b/database/migrations/2017_08_05_174811_SetAllocationUnqiueUsingMultipleFields.php index ea1cb8914..f7aab7c04 100644 --- a/database/migrations/2017_08_05_174811_SetAllocationUnqiueUsingMultipleFields.php +++ b/database/migrations/2017_08_05_174811_SetAllocationUnqiueUsingMultipleFields.php @@ -22,7 +22,9 @@ class SetAllocationUnqiueUsingMultipleFields extends Migration public function down() { Schema::table('allocations', function (Blueprint $table) { + $table->dropForeign(['node_id']); $table->dropUnique(['node_id', 'ip', 'port']); + $table->foreign('node_id')->references('id')->on('nodes'); }); } }