}
public void createTables(DbSchemaGroupMetadata schemaGroupMetadata, String catalog, String schema, int targetVersion, int migrateFromVersion, final TableCreationCallback callback) {
// create
String dbVendorName = _dialect.getDatabaseName();
DbScript createScript = schemaGroupMetadata.getCreateScript(dbVendorName, migrateFromVersion);
if (createScript == null) {
throw new OpenGammaRuntimeException("Missing create script for V" + migrateFromVersion + ", database " + dbVendorName + ", schema group " + schemaGroupMetadata.getSchemaGroupName());
}
s_logger.debug("Creating {} DB version {}", schemaGroupMetadata.getSchemaGroupName(), migrateFromVersion);
s_logger.debug("Executing create script {}", createScript.getName());
executeSQLScript(catalog, schema, createScript);
if (callback != null) {
callback.tablesCreatedOrUpgraded(migrateFromVersion, schemaGroupMetadata);
}
// migrates
for (int v = migrateFromVersion; v < targetVersion; v++) {
DbScript migrateScript = schemaGroupMetadata.getMigrateScript(dbVendorName, v);
if (migrateScript == null) {
throw new OpenGammaRuntimeException("The " + v + " migrate script is missing for " + dbVendorName + " and schema group " + schemaGroupMetadata.getSchemaGroupName());
}
s_logger.debug("Migrating DB from version {} to {}", v, v + 1);
s_logger.debug("Executing migrate script {}", migrateScript.getName());
executeSQLScript(catalog, schema, migrateScript);
if (callback != null) {
callback.tablesCreatedOrUpgraded(v + 1, schemaGroupMetadata);
}
}