| 20 | } |
| 21 | |
| 22 | void AMigrationManager::doMigration() |
| 23 | { |
| 24 | int migrationNumber = AMeta::get("migration").toInt(); |
| 25 | unsigned index = 0; |
| 26 | |
| 27 | |
| 28 | try { |
| 29 | for (auto& m : mMigrations) |
| 30 | { |
| 31 | if (migrationNumber == 0) |
| 32 | { |
| 33 | m.second(); |
| 34 | ALogger::info("Successful migration "_i18n + AString::number(index) + " (" + mMigrations.at(index).first + ")"); |
| 35 | } |
| 36 | else |
| 37 | { |
| 38 | migrationNumber -= 1; |
| 39 | } |
| 40 | ++index; |
| 41 | } |
| 42 | } catch (const AException& e) |
| 43 | { |
| 44 | AError::handle(e, "Could not finish migration "_i18n + AString::number(index) + " (" + mMigrations.at(index).first + ")"); |
| 45 | } |
| 46 | |
| 47 | AMeta::set("migration", index); |
| 48 | } |