@Override public void beforeInvocation() { if (isDisabled() || Play.mode.isProd()) { return; } try { checkEvolutionsState(); } catch (InvalidDatabaseRevision e) { Set<String> dbNames = Configuration.getDbNames(); for (String dbName : dbNames) { Configuration dbConfig = new Configuration(dbName); for (Entry<String, VirtualFile> moduleRoot : modulesWithEvolutions.entrySet()) { if ("mem".equals(dbConfig.getProperty("db")) && listDatabaseEvolutions(e.getDbName(), moduleRoot.getKey()).peek().revision == 0) { Logger.info("Automatically applying evolutions in in-memory database"); Logger.info("Applying evolutions for '" + moduleRoot.getKey() + "'"); applyScript(true, moduleRoot.getKey(), moduleRoot.getValue()); } else { throw e; } } } } }
@Override public void onApplicationStart() { if (!isDisabled()) { populateModulesWithEvolutions(); if (Play.mode.isProd()) { try { checkEvolutionsState(); } catch (InvalidDatabaseRevision e) { Logger.warn(""); Logger.warn("Your database is not up to date."); Logger.warn("Use `play evolutions` command to manage database evolutions."); throw e; } } } }