Allow the migration of sqlite databases

This commit is contained in:
Marcus Moore 2023-03-23 17:40:03 -07:00
parent fc3672c119
commit 317335e79f
No known key found for this signature in database
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');
});
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');
});
}