shared: common: Remove migration logic from ensureConfigured()
Running migrations is okay for initialization. However, doing it here might take ages, so the GUI simply would not show up. Therefore, migration must be done by the CLI or GUI and they should show that migrations are running
Dieser Commit ist enthalten in:
Ursprung
49b57e1740
Commit
c03d7da821
@ -22,17 +22,18 @@ inline void initResources()
|
||||
|
||||
bool Common::initSqliteDatabase(QString path)
|
||||
{
|
||||
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
|
||||
db.setDatabaseName(path);
|
||||
if(!db.open())
|
||||
try
|
||||
{
|
||||
qDebug() << "failed to open database: " << path;
|
||||
initResources();
|
||||
DatabaseFactory factory(path);
|
||||
DBMigrator migrator{factory};
|
||||
migrator.performMigrations();
|
||||
}
|
||||
catch(std::exception &ex)
|
||||
{
|
||||
Logger::error() << "Failed to init dabase: " << ex.what();
|
||||
return false;
|
||||
}
|
||||
initResources();
|
||||
DBMigrator migrator{db};
|
||||
migrator.performMigrations();
|
||||
db.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -89,21 +90,6 @@ void Common::ensureConfigured()
|
||||
}
|
||||
settings.setValue(SETTINGS_KEY_DBPATH, dbpath);
|
||||
}
|
||||
DatabaseFactory factory{dbpath};
|
||||
auto db = factory.forCurrentThread();
|
||||
DBMigrator migrator{db};
|
||||
if(migrator.migrationNeeded())
|
||||
{
|
||||
QFile out;
|
||||
out.open(stderr, QIODevice::WriteOnly);
|
||||
Logger migrationLogger{&out};
|
||||
migrationLogger << "Database is being upgraded, please be patient..." << Qt::endl;
|
||||
QObject::connect(&migrator, &DBMigrator::migrationDone,
|
||||
[&migrationLogger](uint32_t migration)
|
||||
{ migrationLogger << "Progress: Successfully migrated to: " << migration << Qt::endl; });
|
||||
migrator.performMigrations();
|
||||
migrationLogger << "Database upgraded successfully" << Qt::endl;
|
||||
}
|
||||
QVariant pdfViewer = settings.value(SETTINGS_KEY_PDFVIEWER);
|
||||
if(!pdfViewer.isValid())
|
||||
{
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren