From 44eb67440a3db5655fa3786ad06dd06301b4317a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20K=C3=B6llmann?= Date: Wed, 17 Feb 2021 21:57:08 +0100 Subject: [PATCH] Fixed #9115: Duplicate column name 'provider' (#9137) --- ..._05_172502_add_provider_to_oauth_table.php | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/database/migrations/2021_02_05_172502_add_provider_to_oauth_table.php b/database/migrations/2021_02_05_172502_add_provider_to_oauth_table.php index 7c74d47e3..b2dff776e 100644 --- a/database/migrations/2021_02_05_172502_add_provider_to_oauth_table.php +++ b/database/migrations/2021_02_05_172502_add_provider_to_oauth_table.php @@ -14,9 +14,16 @@ class AddProviderToOauthTable extends Migration */ public function up() { - Schema::table('oauth_clients', function (Blueprint $table) { - $table->string('provider')->after('secret')->nullable(); - }); + // Add a 'provider' column if not existing or else modify it + if (!Schema::hasColumn('oauth_clients', 'provider')) { + Schema::table('oauth_clients', function (Blueprint $table) { + $table->string('provider')->after('secret')->nullable(); + }); + } else { + Schema::table('oauth_clients', function (Blueprint $table) { + $table->string('provider')->after('secret')->nullable()->change(); + }); + } } /** @@ -26,9 +33,10 @@ class AddProviderToOauthTable extends Migration */ public function down() { - Schema::table('oauth_clients', function (Blueprint $table) { - $table->dropColumn('provider'); - }); - + if (Schema::hasColumn('oauth_clients', 'provider')) { + Schema::table('oauth_clients', function (Blueprint $table) { + $table->dropColumn('provider'); + }); + } } }