Skip to content

A free open source IT asset/license management system

Fixed #9115: Duplicate column name 'provider' (#9137)

Kevin Köllmann44eb67440a3d
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 7c74d47e3b..b2dff776e7 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');
+ });
+ }
}
}