use of com.haulmont.cuba.core.sys.DbUpdater in project cuba by cuba-platform.
the class DbUpdateManager method checkDatabase.
protected void checkDatabase(String storeName) {
DbUpdater dbUpdater = AppBeans.getPrototype(DbUpdater.NAME, storeName);
try {
boolean initialized = false;
try {
initialized = dbUpdater.dbInitialized();
} catch (DbInitializationException e) {
if (!Stores.isMain(storeName)) {
return;
}
}
if (!initialized) {
throw new IllegalStateException(StringHelper.wrapLogMessage("ERROR: Data store " + (Stores.isMain(storeName) ? "" : "[" + storeNameToString(storeName) + "]") + "is not initialized. " + getLogString(storeName)));
}
List<String> scripts = dbUpdater.findUpdateDatabaseScripts();
if (!scripts.isEmpty()) {
log.warn(StringHelper.wrapLogMessage("WARNING: The application contains unapplied update scripts for data store" + (Stores.isMain(storeName) ? "" : " [" + storeNameToString(storeName) + "]") + ":\n\n" + Joiner.on('\n').join(scripts) + "\n\n" + getLogString(storeName)));
}
} catch (DbInitializationException e) {
throw new RuntimeException(StringHelper.wrapLogMessage("ERROR: Cannot check data store [" + storeNameToString(storeName) + "]. See the stacktrace below for details."), e);
}
}
Aggregations