Merge pull request #12721 from marcusmoore/fixes/allow-migrating-sqlite

Fixes the migration of sqlite databases
This commit is contained in:
snipe 2023-03-24 04:50:15 -07:00 committed by GitHub
commit 3792d3fdd2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 5 deletions

View file

@ -22,7 +22,7 @@ class AddIdsToTables extends Migration
Schema::table('password_resets', function (Blueprint $table) {
// Add the id column to the password_resets table if it doesn't yet have one
if (! Schema::hasColumn('password_resets', 'id')) {
if (! Schema::hasColumn('password_resets', 'id') && $this->notUsingSqlite()) {
$table->increments('id');
}
});
@ -47,4 +47,9 @@ class AddIdsToTables extends Migration
}
});
}
private function notUsingSqlite()
{
return Schema::connection($this->getConnection())->getConnection()->getDriverName() !== 'sqlite';
}
}

View file

@ -13,12 +13,27 @@ class AddsWebhookOptionToSettingsTable extends Migration
*/
public function up()
{
/**
* So...you're probably wondering why this isn't all in one Schema::table()...
* Turns out we'll get the following error:
* "SQLite doesn't support multiple calls to dropColumn / renameColumn in a single modification."
* if we're running sqlite so a solution is to make multiple calls.
* ¯\_()_/¯
*/
Schema::table('settings', function (Blueprint $table) {
$table->string('webhook_selected')->after('slack_botname')->default('slack')->nullable();
$table->renameColumn('slack_botname', 'webhook_botname');
$table->renameColumn('slack_endpoint', 'webhook_endpoint');
$table->renameColumn('slack_channel', 'webhook_channel');
$table->string('webhook_selected')->after('slack_botname')->default('slack')->nullable();
});
Schema::table('settings', function (Blueprint $table) {
$table->renameColumn('slack_botname', 'webhook_botname');
});
Schema::table('settings', function (Blueprint $table) {
$table->renameColumn('slack_endpoint', 'webhook_endpoint');
});
Schema::table('settings', function (Blueprint $table) {
$table->renameColumn('slack_channel', 'webhook_channel');
});
}