From 223041bc6b0c29fbe82fc62e7da018a52104835e Mon Sep 17 00:00:00 2001 From: Hynek Mlnarik Date: Mon, 14 Nov 2016 13:57:57 +0100 Subject: [PATCH] KEYCLOAK-3734 Unify master changelog of DB2 and other databases --- .../LiquibaseJpaUpdaterProvider.java | 3 +- .../DefaultLiquibaseConnectionProvider.java | 5 +-- .../META-INF/db2-jpa-changelog-master.xml | 40 ------------------- ....xml => jpa-changelog-1.0.0.Final-db2.xml} | 6 ++- .../META-INF/jpa-changelog-1.0.0.Final.xml | 6 +++ ....xml => jpa-changelog-1.2.0.Beta1-db2.xml} | 6 ++- .../META-INF/jpa-changelog-1.2.0.Beta1.xml | 6 +++ ...R1.xml => jpa-changelog-1.2.0.CR1-db2.xml} | 6 ++- .../META-INF/jpa-changelog-1.2.0.CR1.xml | 6 +++ ...-1.4.0.xml => jpa-changelog-1.4.0-db2.xml} | 6 ++- .../META-INF/jpa-changelog-1.4.0.xml | 6 +++ ...-1.8.0.xml => jpa-changelog-1.8.0-db2.xml} | 9 ++++- .../META-INF/jpa-changelog-1.8.0.xml | 11 +++++ ...-1.9.1.xml => jpa-changelog-1.9.1-db2.xml} | 6 ++- .../META-INF/jpa-changelog-1.9.1.xml | 6 +++ .../META-INF/jpa-changelog-master.xml | 6 +++ 16 files changed, 83 insertions(+), 51 deletions(-) delete mode 100644 model/jpa/src/main/resources/META-INF/db2-jpa-changelog-master.xml rename model/jpa/src/main/resources/META-INF/{db2-jpa-changelog-1.0.0.Final.xml => jpa-changelog-1.0.0.Final-db2.xml} (98%) rename model/jpa/src/main/resources/META-INF/{db2-jpa-changelog-1.2.0.Beta1.xml => jpa-changelog-1.2.0.Beta1-db2.xml} (96%) rename model/jpa/src/main/resources/META-INF/{db2-jpa-changelog-1.2.0.CR1.xml => jpa-changelog-1.2.0.CR1-db2.xml} (96%) rename model/jpa/src/main/resources/META-INF/{db2-jpa-changelog-1.4.0.xml => jpa-changelog-1.4.0-db2.xml} (94%) rename model/jpa/src/main/resources/META-INF/{db2-jpa-changelog-1.8.0.xml => jpa-changelog-1.8.0-db2.xml} (93%) rename model/jpa/src/main/resources/META-INF/{db2-jpa-changelog-1.9.1.xml => jpa-changelog-1.9.1-db2.xml} (75%) diff --git a/model/jpa/src/main/java/org/keycloak/connections/jpa/updater/liquibase/LiquibaseJpaUpdaterProvider.java b/model/jpa/src/main/java/org/keycloak/connections/jpa/updater/liquibase/LiquibaseJpaUpdaterProvider.java index 48c41fddf2..8e50205fd6 100755 --- a/model/jpa/src/main/java/org/keycloak/connections/jpa/updater/liquibase/LiquibaseJpaUpdaterProvider.java +++ b/model/jpa/src/main/java/org/keycloak/connections/jpa/updater/liquibase/LiquibaseJpaUpdaterProvider.java @@ -55,7 +55,6 @@ public class LiquibaseJpaUpdaterProvider implements JpaUpdaterProvider { private static final Logger logger = Logger.getLogger(LiquibaseJpaUpdaterProvider.class); public static final String CHANGELOG = "META-INF/jpa-changelog-master.xml"; - public static final String DB2_CHANGELOG = "META-INF/db2-jpa-changelog-master.xml"; private final KeycloakSession session; @@ -99,7 +98,7 @@ public class LiquibaseJpaUpdaterProvider implements JpaUpdaterProvider { updateChangeSet(liquibase, liquibase.getChangeLogFile(), exportWriter); } } - } catch (Exception e) { + } catch (LiquibaseException | IOException e) { throw new RuntimeException("Failed to update database", e); } finally { ThreadLocalSessionContext.removeCurrentSession(); diff --git a/model/jpa/src/main/java/org/keycloak/connections/jpa/updater/liquibase/conn/DefaultLiquibaseConnectionProvider.java b/model/jpa/src/main/java/org/keycloak/connections/jpa/updater/liquibase/conn/DefaultLiquibaseConnectionProvider.java index 3bd2643d78..438d76b0f7 100644 --- a/model/jpa/src/main/java/org/keycloak/connections/jpa/updater/liquibase/conn/DefaultLiquibaseConnectionProvider.java +++ b/model/jpa/src/main/java/org/keycloak/connections/jpa/updater/liquibase/conn/DefaultLiquibaseConnectionProvider.java @@ -22,7 +22,6 @@ import liquibase.changelog.ChangeSet; import liquibase.changelog.DatabaseChangeLog; import liquibase.database.Database; import liquibase.database.DatabaseFactory; -import liquibase.database.core.DB2Database; import liquibase.database.jvm.JdbcConnection; import liquibase.exception.LiquibaseException; import liquibase.logging.LogFactory; @@ -129,7 +128,7 @@ public class DefaultLiquibaseConnectionProvider implements LiquibaseConnectionPr database.setDefaultSchemaName(defaultSchema); } - String changelog = (database instanceof DB2Database) ? LiquibaseJpaUpdaterProvider.DB2_CHANGELOG : LiquibaseJpaUpdaterProvider.CHANGELOG; + String changelog = LiquibaseJpaUpdaterProvider.CHANGELOG; ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor(getClass().getClassLoader()); logger.debugf("Using changelog file %s and changelogTableName %s", changelog, database.getDatabaseChangeLogTableName()); @@ -154,7 +153,7 @@ public class DefaultLiquibaseConnectionProvider implements LiquibaseConnectionPr private static class LogWrapper extends LogFactory { - private liquibase.logging.Logger logger = new liquibase.logging.Logger() { + private static final liquibase.logging.Logger logger = new liquibase.logging.Logger() { @Override public void setName(String name) { } diff --git a/model/jpa/src/main/resources/META-INF/db2-jpa-changelog-master.xml b/model/jpa/src/main/resources/META-INF/db2-jpa-changelog-master.xml deleted file mode 100644 index cc4c9ff016..0000000000 --- a/model/jpa/src/main/resources/META-INF/db2-jpa-changelog-master.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/model/jpa/src/main/resources/META-INF/db2-jpa-changelog-1.0.0.Final.xml b/model/jpa/src/main/resources/META-INF/jpa-changelog-1.0.0.Final-db2.xml similarity index 98% rename from model/jpa/src/main/resources/META-INF/db2-jpa-changelog-1.0.0.Final.xml rename to model/jpa/src/main/resources/META-INF/jpa-changelog-1.0.0.Final-db2.xml index 6e1c8af731..b1817c1909 100644 --- a/model/jpa/src/main/resources/META-INF/db2-jpa-changelog-1.0.0.Final.xml +++ b/model/jpa/src/main/resources/META-INF/jpa-changelog-1.0.0.Final-db2.xml @@ -16,8 +16,12 @@ ~ limitations under the License. --> - + + + + + diff --git a/model/jpa/src/main/resources/META-INF/jpa-changelog-1.0.0.Final.xml b/model/jpa/src/main/resources/META-INF/jpa-changelog-1.0.0.Final.xml index a113601ed8..7869f1e26a 100644 --- a/model/jpa/src/main/resources/META-INF/jpa-changelog-1.0.0.Final.xml +++ b/model/jpa/src/main/resources/META-INF/jpa-changelog-1.0.0.Final.xml @@ -18,6 +18,12 @@ + + + + + + diff --git a/model/jpa/src/main/resources/META-INF/db2-jpa-changelog-1.2.0.Beta1.xml b/model/jpa/src/main/resources/META-INF/jpa-changelog-1.2.0.Beta1-db2.xml similarity index 96% rename from model/jpa/src/main/resources/META-INF/db2-jpa-changelog-1.2.0.Beta1.xml rename to model/jpa/src/main/resources/META-INF/jpa-changelog-1.2.0.Beta1-db2.xml index a23c6b2912..41abd07729 100644 --- a/model/jpa/src/main/resources/META-INF/db2-jpa-changelog-1.2.0.Beta1.xml +++ b/model/jpa/src/main/resources/META-INF/jpa-changelog-1.2.0.Beta1-db2.xml @@ -16,8 +16,12 @@ ~ limitations under the License. --> - + + + + + diff --git a/model/jpa/src/main/resources/META-INF/jpa-changelog-1.2.0.Beta1.xml b/model/jpa/src/main/resources/META-INF/jpa-changelog-1.2.0.Beta1.xml index de34d28a0e..4e072673c8 100755 --- a/model/jpa/src/main/resources/META-INF/jpa-changelog-1.2.0.Beta1.xml +++ b/model/jpa/src/main/resources/META-INF/jpa-changelog-1.2.0.Beta1.xml @@ -18,6 +18,12 @@ + + + + + + diff --git a/model/jpa/src/main/resources/META-INF/db2-jpa-changelog-1.2.0.CR1.xml b/model/jpa/src/main/resources/META-INF/jpa-changelog-1.2.0.CR1-db2.xml similarity index 96% rename from model/jpa/src/main/resources/META-INF/db2-jpa-changelog-1.2.0.CR1.xml rename to model/jpa/src/main/resources/META-INF/jpa-changelog-1.2.0.CR1-db2.xml index edb8ca7248..49e647c6f5 100644 --- a/model/jpa/src/main/resources/META-INF/db2-jpa-changelog-1.2.0.CR1.xml +++ b/model/jpa/src/main/resources/META-INF/jpa-changelog-1.2.0.CR1-db2.xml @@ -16,8 +16,12 @@ ~ limitations under the License. --> - + + + + + diff --git a/model/jpa/src/main/resources/META-INF/jpa-changelog-1.2.0.CR1.xml b/model/jpa/src/main/resources/META-INF/jpa-changelog-1.2.0.CR1.xml index 3a7c6baa9f..5c9b676ac1 100755 --- a/model/jpa/src/main/resources/META-INF/jpa-changelog-1.2.0.CR1.xml +++ b/model/jpa/src/main/resources/META-INF/jpa-changelog-1.2.0.CR1.xml @@ -18,6 +18,12 @@ + + + + + + diff --git a/model/jpa/src/main/resources/META-INF/db2-jpa-changelog-1.4.0.xml b/model/jpa/src/main/resources/META-INF/jpa-changelog-1.4.0-db2.xml similarity index 94% rename from model/jpa/src/main/resources/META-INF/db2-jpa-changelog-1.4.0.xml rename to model/jpa/src/main/resources/META-INF/jpa-changelog-1.4.0-db2.xml index 498810c3a2..b16fbbedf4 100644 --- a/model/jpa/src/main/resources/META-INF/db2-jpa-changelog-1.4.0.xml +++ b/model/jpa/src/main/resources/META-INF/jpa-changelog-1.4.0-db2.xml @@ -16,8 +16,12 @@ ~ limitations under the License. --> - + + + + + diff --git a/model/jpa/src/main/resources/META-INF/jpa-changelog-1.4.0.xml b/model/jpa/src/main/resources/META-INF/jpa-changelog-1.4.0.xml index 1b47050117..a8bfc97e6a 100755 --- a/model/jpa/src/main/resources/META-INF/jpa-changelog-1.4.0.xml +++ b/model/jpa/src/main/resources/META-INF/jpa-changelog-1.4.0.xml @@ -18,6 +18,12 @@ + + + + + + diff --git a/model/jpa/src/main/resources/META-INF/db2-jpa-changelog-1.8.0.xml b/model/jpa/src/main/resources/META-INF/jpa-changelog-1.8.0-db2.xml similarity index 93% rename from model/jpa/src/main/resources/META-INF/db2-jpa-changelog-1.8.0.xml rename to model/jpa/src/main/resources/META-INF/jpa-changelog-1.8.0-db2.xml index dfbf38b9c9..f43b8a4fa8 100644 --- a/model/jpa/src/main/resources/META-INF/db2-jpa-changelog-1.8.0.xml +++ b/model/jpa/src/main/resources/META-INF/jpa-changelog-1.8.0-db2.xml @@ -16,8 +16,11 @@ ~ limitations under the License. --> - + + + + @@ -134,6 +137,10 @@ + + + + diff --git a/model/jpa/src/main/resources/META-INF/jpa-changelog-1.8.0.xml b/model/jpa/src/main/resources/META-INF/jpa-changelog-1.8.0.xml index 79ba2fc3d1..5ebd8d40f7 100755 --- a/model/jpa/src/main/resources/META-INF/jpa-changelog-1.8.0.xml +++ b/model/jpa/src/main/resources/META-INF/jpa-changelog-1.8.0.xml @@ -18,6 +18,11 @@ + + + + + @@ -130,6 +135,12 @@ + + + + + + diff --git a/model/jpa/src/main/resources/META-INF/db2-jpa-changelog-1.9.1.xml b/model/jpa/src/main/resources/META-INF/jpa-changelog-1.9.1-db2.xml similarity index 75% rename from model/jpa/src/main/resources/META-INF/db2-jpa-changelog-1.9.1.xml rename to model/jpa/src/main/resources/META-INF/jpa-changelog-1.9.1-db2.xml index d0b387dab2..42558a7063 100644 --- a/model/jpa/src/main/resources/META-INF/db2-jpa-changelog-1.9.1.xml +++ b/model/jpa/src/main/resources/META-INF/jpa-changelog-1.9.1-db2.xml @@ -16,8 +16,12 @@ ~ limitations under the License. --> - + + + + + diff --git a/model/jpa/src/main/resources/META-INF/jpa-changelog-1.9.1.xml b/model/jpa/src/main/resources/META-INF/jpa-changelog-1.9.1.xml index f801ddc19e..c083bc9a2b 100755 --- a/model/jpa/src/main/resources/META-INF/jpa-changelog-1.9.1.xml +++ b/model/jpa/src/main/resources/META-INF/jpa-changelog-1.9.1.xml @@ -18,6 +18,12 @@ + + + + + + diff --git a/model/jpa/src/main/resources/META-INF/jpa-changelog-master.xml b/model/jpa/src/main/resources/META-INF/jpa-changelog-master.xml index 8990fc438c..dc16e0d351 100755 --- a/model/jpa/src/main/resources/META-INF/jpa-changelog-master.xml +++ b/model/jpa/src/main/resources/META-INF/jpa-changelog-master.xml @@ -18,19 +18,25 @@ + + + + + +