Liquibase liquibase = getLiquibase(CHANGE_LOG_FILE, null); database = liquibase.getDatabase(); DatabaseChangeLog changeLog = new XMLChangeLogSAXParser().parse(CHANGE_LOG_FILE, new ChangeLogParameters(), liquibase.getFileOpener()); List<ChangeSet> changeSets = changeLog.getChangeSets();
@Override public String getValue(final String uri, final String localName) { return changeLogParameters.expandExpressions(attributes.getValue(uri, localName)); } }
@Override public void applyChangelog( Map<String, Object> parameters ) throws SQLException, LiquibaseException { Liquibase liquibase = null; try { liquibase = newConnectedLiquibase(); for( Map.Entry<String, Object> entry : parameters.entrySet() ) { liquibase.getChangeLogParameters().set( entry.getKey(), entry.getValue() ); } liquibase.update( config.get().contexts().get() ); } finally { if( liquibase != null ) { liquibase.getDatabase().close(); } } } }
@Override public void applyChangelog( Map<String, Object> parameters ) throws SQLException, LiquibaseException { Liquibase liquibase = null; try { liquibase = newConnectedLiquibase(); for( Map.Entry<String, Object> entry : parameters.entrySet() ) { liquibase.getChangeLogParameters().set( entry.getKey(), entry.getValue() ); } liquibase.update( config.get().contexts().get() ); } finally { if( liquibase != null ) { liquibase.getDatabase().close(); } } } }
String dbms = StringUtils.trimToNull(atts.getValue("dbms")); if (StringUtils.trimToNull(atts.getValue("file")) == null) { changeLogParameters.set(atts.getValue("name"), atts.getValue("value"), context, dbms); } else { Properties props = new Properties(); changeLogParameters.set(entry.getKey().toString(), entry.getValue().toString(), context, dbms);
/** * Interface used for callbacks when updating the database. Implement this interface and pass it * to {@link DatabaseUpdater#executeChangelog(String, Map, ChangeSetExecutorCallback)} */ public interface ChangeSetExecutorCallback { /** * This method is called after each changeset is executed. * * @param changeSet the liquibase changeset that was just run * @param numChangeSetsToRun the total number of changesets in the current file */ public void executing(ChangeSet changeSet, int numChangeSetsToRun); }
@Override public String getValue(final String qName) { return changeLogParameters.expandExpressions(attributes.getValue(qName)); }
params.set("currentDateTime", new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(new Date()));
ChangeLogParser parser = ChangeLogParserFactory.getInstance().getParser("src/main/resources/changelog.xml", resourceAccessor); DatabaseChangeLog databaseChangeLog = parser.parse("src/main/resources/changelog.xml", new ChangeLogParameters(), resourceAccessor);
private void setProperty(final Object object, final String attributeName, final String attributeValue) throws IllegalAccessException, InvocationTargetException, CustomChangeException { if (object instanceof CustomChangeWrapper) { if (attributeName.equals("class")) { ((CustomChangeWrapper) object).setClass(changeLogParameters.expandExpressions(attributeValue)); } else { ((CustomChangeWrapper) object).setParam(attributeName, changeLogParameters.expandExpressions(attributeValue)); } } else { ObjectUtil.setProperty(object, attributeName, changeLogParameters.expandExpressions(attributeValue)); } }
params.set("currentDateTime", new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(new Date()));
String textString = null; if ((text != null) && (text.length() > 0)) { textString = changeLogParameters.expandExpressions(StringUtils.trimToNull(text.toString())); expandedExpression = changeLogParameters.expandExpressions(textString);
private void applyLiquibaseChangelog( SQLDialect dialect ) throws SQLException, LiquibaseException { Liquibase liquibase = liquibaseService.newConnectedLiquibase(); Database db = liquibase.getDatabase(); db.setObjectQuotingStrategy( ObjectQuotingStrategy.QUOTE_ALL_OBJECTS ); try { if( !dialect.equals( SQLDialect.SQLITE ) ) { if( db.supportsSchemas() ) { db.setDefaultSchemaName( schema.getName() ); db.setLiquibaseSchemaName( schema.getName() ); } if( db.supportsCatalogs() ) { db.setDefaultCatalogName( schema.getName() ); db.setLiquibaseCatalogName( schema.getName() ); } } liquibase.getChangeLogParameters().set( TABLE_NAME_LIQUIBASE_PARAMETER, table.getName() ); liquibase.update( new Contexts() ); } finally { db.close(); } }