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

This commit is contained in:
Kevin Köllmann 2021-02-17 21:57:08 +01:00 committed by GitHub
parent 834e0a9dd5
commit 44eb67440a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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');
});
}
}
}