Skip to content

Commit

Permalink
[playframework#1383] 🆕 Add the ability to disable database evolutions…
Browse files Browse the repository at this point in the history
… on a datasource basis
  • Loading branch information
holajsh committed Feb 15, 2022
1 parent d30db81 commit d691d6e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion framework/src/play/db/Evolutions.java
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,10 @@ private boolean isDisabled() {
return "false".equals(Play.configuration.getProperty("evolutions.enabled", "true"));
}

private static boolean isDatabaseEvolutionDisabled(String dbName) {
return "false".equals(Play.configuration.getProperty("db." + dbName + ".evolutions.enabled", "true"));
}

private static boolean isModuleEvolutionDisabled() {
return "false".equals(Play.configuration.getProperty("modules.evolutions.enabled", "true"));
}
Expand Down Expand Up @@ -501,7 +505,9 @@ public static synchronized void checkEvolutionsState() {
// Look over all the DB
Set<String> dBNames = Configuration.getDbNames();
for (String dbName : dBNames) {
checkEvolutionsState(dbName);
if (!isDatabaseEvolutionDisabled(dbName)) {
checkEvolutionsState(dbName);
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions framework/test-src/play/db/ConfigurationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ public void getPropertiesForDBTest() {
Play.configuration.put("db.test.pool.maxSize", "20");
Play.configuration.put("db.test.pool.minSize", "1");
Play.configuration.put("db.test.pool.maxIdleTimeExcessConnections", "60");
Play.configuration.put("db.test.evolutions.enabled", "false");
//javax.persistence
Play.configuration.put("javax.persistence.test.lock.scope", "EXTENDED");
Play.configuration.put("javax.persistence.test.lock.timeout", "1000");
Expand All @@ -327,6 +328,7 @@ public void getPropertiesForDBTest() {
assertEquals("20", properties.get("db.pool.maxSize"));
assertEquals("1", properties.get("db.pool.minSize"));
assertEquals("60", properties.get("db.pool.maxIdleTimeExcessConnections"));
assertEquals("false", properties.get("db.evolutions.enabled"));
//javax.persistence
assertEquals("EXTENDED", properties.get("javax.persistence.lock.scope"));
assertEquals("1000", properties.get("javax.persistence.lock.timeout"));
Expand Down

0 comments on commit d691d6e

Please sign in to comment.