From c52e3b5f9c8eadc01b54f3642b0dc9eca145ee0f Mon Sep 17 00:00:00 2001 From: Daniel Meltzer Date: Fri, 20 May 2016 10:03:04 -0500 Subject: [PATCH] Check if the column exists before dropping. Also recreate the column in a rollback to make the migrations happy. Also break into two migrations to make sqlite happy. --- ...remove_option_keys_from_settings_table.php | 5 +-- ...emove_option_value_from_settings_table.php | 34 +++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 database/migrations/2016_05_20_143758_remove_option_value_from_settings_table.php diff --git a/database/migrations/2016_05_20_024859_remove_option_keys_from_settings_table.php b/database/migrations/2016_05_20_024859_remove_option_keys_from_settings_table.php index 0ac3ddd58bc9..d89677f34553 100644 --- a/database/migrations/2016_05_20_024859_remove_option_keys_from_settings_table.php +++ b/database/migrations/2016_05_20_024859_remove_option_keys_from_settings_table.php @@ -14,8 +14,8 @@ public function up() { Schema::table('settings', function (Blueprint $table) { // - $table->dropColumn('option_name'); - $table->dropColumn('option_value'); + if(Schema::hasColumn('option_name', 'settings')) + $table->dropColumn('option_name'); }); } @@ -28,6 +28,7 @@ public function down() { Schema::table('Settings', function (Blueprint $table) { // + $table->string('option_name')->nullable(); }); } } diff --git a/database/migrations/2016_05_20_143758_remove_option_value_from_settings_table.php b/database/migrations/2016_05_20_143758_remove_option_value_from_settings_table.php new file mode 100644 index 000000000000..302baaa8cbd3 --- /dev/null +++ b/database/migrations/2016_05_20_143758_remove_option_value_from_settings_table.php @@ -0,0 +1,34 @@ +dropColumn('option_value'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + Schema::table('settings', function (Blueprint $table) { + $table->string('option_value')->nullable(); + }); + } +}