Exemple #1
0
 private IUpgrade findNextUpgrade(IDatabase database) {
   int version = database.getVersion();
   for (IUpgrade upgrade : upgrades) {
     for (int upgradeVersion : upgrade.getInitialVersions()) {
       if (upgradeVersion == version) return upgrade;
     }
   }
   return null;
 }
Exemple #2
0
 private void run(IDatabase database) throws Exception {
   IUpgrade nextUpgrade = null;
   while ((nextUpgrade = findNextUpgrade(database)) != null) {
     log.trace(
         "execute update from v({}) to v{}",
         nextUpgrade.getInitialVersions(),
         nextUpgrade.getEndVersion());
     nextUpgrade.exec(database);
     updateVersion(nextUpgrade.getEndVersion(), database);
   }
   log.trace("no more upgrades");
 }