mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-18 02:03:40 +00:00
Code to facilitate #1123
This commit is contained in:
37
database/seeds/ConfigSeeder.php
Normal file
37
database/seeds/ConfigSeeder.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use FireflyIII\Models\Configuration;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
/**
|
||||
* Class ConfigSeeder
|
||||
*/
|
||||
class ConfigSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$entry = Configuration::where('name', 'db_version')->first();
|
||||
if (is_null($entry)) {
|
||||
Log::warning('No database version entry is present. Database is assumed to be OLD (version 1).');
|
||||
// FF old or no version present. Put at 1:
|
||||
Configuration::create(
|
||||
[
|
||||
'name' => 'db_version',
|
||||
'data' => 1,
|
||||
]
|
||||
);
|
||||
}
|
||||
if (!is_null($entry)) {
|
||||
$version = intval(config('firefly.db_version'));
|
||||
$entry->data = $version;
|
||||
$entry->save();
|
||||
|
||||
Log::warning(sprintf('Database entry exists. Update to latest version (%d)', $version));
|
||||
}
|
||||
}
|
||||
}
|
@@ -37,5 +37,6 @@ class DatabaseSeeder extends Seeder
|
||||
$this->call(TransactionTypeSeeder::class);
|
||||
$this->call(PermissionSeeder::class);
|
||||
$this->call(LinkTypeSeeder::class);
|
||||
$this->call(ConfigSeeder::class);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user