mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Allow the migration of sqlite databases
This commit is contained in:
parent
fc3672c119
commit
317335e79f
|
@ -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';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue