cli: Run migrations if necessary

This commit is contained in:
Albert S. 2022-07-28 14:28:45 +02:00
부모 1da8344295
커밋 1188e51c35
1개의 변경된 파일22개의 추가작업 그리고 0개의 파일을 삭제

파일 보기

@ -26,6 +26,7 @@
#include "sandboxedprocessor.h"
#include "../shared/common.h"
#include "../shared/filescanworker.h"
#include "../shared/dbmigrator.h"
void printUsage(QString argv0)
{
@ -75,6 +76,27 @@ int main(int argc, char *argv[])
try
{
Common::ensureConfigured();
DatabaseFactory factory{Common::databasePath()};
DBMigrator migrator{factory};
if(migrator.migrationNeeded())
{
Logger::info() << "Database is being upgraded, please be patient..." << Qt::endl;
QObject::connect(&migrator, &DBMigrator::migrationDone,
[&](uint32_t migration)
{ Logger::info() << "Progress: Successfully migrated to: " << migration << Qt::endl; });
QObject::connect(&migrator, &DBMigrator::done,
[]() { Logger::info() << "Database upgrade successful" << Qt::endl; });
QObject::connect(&migrator, &DBMigrator::error,
[&](QString error)
{
Logger::error() << error << Qt::endl;
qApp->quit();
});
migrator.performMigrations();
}
}
catch(LooqsGeneralException &e)
{