KEYCLOAK-3698 Manual migration - custom JpaEntityProvide changelog table

Reflect in the SQL script that custom JpaEntityProviders have their
own changelog tables, and issue DDL commands to create them when
initializing a new database.
This commit is contained in:
Hynek Mlnarik 2016-10-19 11:59:35 +02:00
parent f2f508ac2e
commit 49d3d3f6e3

View file

@ -85,12 +85,7 @@ public class LiquibaseJpaUpdaterProvider implements JpaUpdaterProvider {
Liquibase liquibase = getLiquibaseForKeycloakUpdate(connection, defaultSchema); Liquibase liquibase = getLiquibaseForKeycloakUpdate(connection, defaultSchema);
if (file != null) { if (file != null) {
exportWriter = new FileWriter(file); exportWriter = new FileWriter(file);
List<ChangeSet> changeSets = getChangeSets(liquibase);
if (! changeSets.isEmpty() && liquibase.getDatabase().getRanChangeSetList().isEmpty()) {
outputChangeLogTableCreationScript(liquibase, exportWriter);
} }
}
updateChangeSet(liquibase, liquibase.getChangeLogFile(), exportWriter); updateChangeSet(liquibase, liquibase.getChangeLogFile(), exportWriter);
// Run update for each custom JpaEntityProvider // Run update for each custom JpaEntityProvider
@ -118,7 +113,6 @@ public class LiquibaseJpaUpdaterProvider implements JpaUpdaterProvider {
} }
} }
protected void updateChangeSet(Liquibase liquibase, String changelog, Writer exportWriter) throws LiquibaseException, IOException { protected void updateChangeSet(Liquibase liquibase, String changelog, Writer exportWriter) throws LiquibaseException, IOException {
List<ChangeSet> changeSets = getChangeSets(liquibase); List<ChangeSet> changeSets = getChangeSets(liquibase);
if (!changeSets.isEmpty()) { if (!changeSets.isEmpty()) {
@ -134,6 +128,9 @@ public class LiquibaseJpaUpdaterProvider implements JpaUpdaterProvider {
} }
if (exportWriter != null) { if (exportWriter != null) {
if (ranChangeSets.isEmpty()) {
outputChangeLogTableCreationScript(liquibase, exportWriter);
}
liquibase.update((Contexts) null, new LabelExpression(), exportWriter, false); liquibase.update((Contexts) null, new LabelExpression(), exportWriter, false);
} else { } else {
liquibase.update((Contexts) null); liquibase.update((Contexts) null);