// drop tables
if (shouldDropTables) {
ListIterator<DbEntity> it = dbEntitiesInInsertOrder
.listIterator(dbEntitiesInInsertOrder.size());
while (it.hasPrevious()) {
DbEntity ent = it.previous();
for (String statement : dropTables.get(ent.getName())) {
safeExecute(connection, statement);
}
}
}
// create tables
List<String> createdTables = new ArrayList<String>();
if (shouldCreateTables) {
for (final DbEntity ent : dbEntitiesInInsertOrder) {
// only create missing tables
safeExecute(connection, createTables.get(ent.getName()));
createdTables.add(ent.getName());
}
}
// create FK
if (shouldCreateTables && shouldCreateFKConstraints) {
for (DbEntity ent : dbEntitiesInInsertOrder) {
if (createdTables.contains(ent.getName())) {
List<String> fks = createConstraints.get(ent.getName());
for (String fk : fks) {
safeExecute(connection, fk);
}
}
}