From db35f0f5ed8f1a815bc0b188988d45da11dc1d93 Mon Sep 17 00:00:00 2001 From: rob bygrave Date: Thu, 9 Aug 2018 21:34:23 +1200 Subject: [PATCH] #1466 - With ebean.dbSchema property (aka default db schema) we should not connection.setSchema() when running migrations --- pom.xml | 2 +- .../io/ebean/config/DbMigrationConfig.java | 20 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index f2f64fa2f..764c2b2e5 100644 --- a/pom.xml +++ b/pom.xml @@ -135,7 +135,7 @@ io.ebean ebean-migration - 11.8.1 + 11.8.2 diff --git a/src/main/java/io/ebean/config/DbMigrationConfig.java b/src/main/java/io/ebean/config/DbMigrationConfig.java index f40f6f58d..d09f3430a 100644 --- a/src/main/java/io/ebean/config/DbMigrationConfig.java +++ b/src/main/java/io/ebean/config/DbMigrationConfig.java @@ -107,6 +107,11 @@ public class DbMigrationConfig { */ protected String dbSchema; + /** + * Set to true if we consider this the 'default schema' (Postgres schema that matches DB username) + */ + protected boolean defaultDbSchema; + /** * DB user used to run the DB migration. */ @@ -400,9 +405,15 @@ public class DbMigrationConfig { * Set the Db schema if it hasn't already been defined. */ public void setDefaultDbSchema(String dbSchema) { - if (this.dbSchema == null) { - this.dbSchema = dbSchema; - } + this.defaultDbSchema = true; + this.dbSchema = dbSchema; + } + + /** + * Return true if this is considered the default DB schema (Postgres schema matching DB username). + */ + public boolean isDefaultDbSchema() { + return defaultDbSchema; } /** @@ -591,6 +602,9 @@ public class DbMigrationConfig { runnerConfig.setDbUsername(getDbUsername()); runnerConfig.setDbPassword(getDbPassword()); runnerConfig.setDbSchema(getDbSchema()); + if (defaultDbSchema) { + runnerConfig.setSetCurrentSchema(false); + } runnerConfig.setClassLoader(classLoader); if (patchInsertOn != null) { runnerConfig.setPatchInsertOn(patchInsertOn);