private List<SchemaVersion> pending(int curr) { List<SchemaVersion> r = Lists.newArrayListWithCapacity(versionNbr - curr); for (SchemaVersion v = this; curr < v.getVersionNbr(); v = v.prior.get()) { r.add(v); } Collections.reverse(r); return r; }
private void migrateData( List<SchemaVersion> pending, UpdateUI ui, CurrentSchemaVersion curr, ReviewDb db) throws OrmException, SQLException { for (SchemaVersion v : pending) { ui.message(String.format("Migrating data to schema %d ...", v.getVersionNbr())); v.migrateData(db, ui); v.finish(curr, db); } }
private void updateSchema(List<SchemaVersion> pending, UpdateUI ui, ReviewDb db) throws OrmException, SQLException { for (SchemaVersion v : pending) { ui.message(String.format("Upgrading schema to %d ...", v.getVersionNbr())); v.preUpdateSchema(db); } JdbcSchema s = (JdbcSchema) db; try (JdbcExecutor e = new JdbcExecutor(s)) { s.updateSchema(e); } }