本文整理了Java中liquibase.Liquibase.listUnrunChangeSets()
方法的一些代码示例,展示了Liquibase.listUnrunChangeSets()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Liquibase.listUnrunChangeSets()
方法的具体详情如下:
包路径:liquibase.Liquibase
类名称:Liquibase
方法名:listUnrunChangeSets
暂无
代码示例来源:origin: openmrs/openmrs-core
Liquibase liquibase = getLiquibase(changelogFile, null);
database = liquibase.getDatabase();
List<ChangeSet> changeSets = liquibase.listUnrunChangeSets(CONTEXT);
代码示例来源:origin: openmrs/openmrs-core
/**
* 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);
}
代码示例来源:origin: com.blazebit/blaze-weblink-core-model
public void update(Connection connection) {
logger.fine("Starting database update");
try {
Liquibase liquibase = getLiquibase(connection);
List<ChangeSet> changeSets = liquibase.listUnrunChangeSets((Contexts) null);
if (!changeSets.isEmpty()) {
if (changeSets.get(0).getId().equals(FIRST_VERSION)) {
logger.info("Initializing database schema");
} else {
if (logger.isLoggable(Level.FINE)) {
List<RanChangeSet> ranChangeSets = liquibase.getDatabase().getRanChangeSetList();
final String msg = MessageFormat.format("Updating database from {0} to {1}", ranChangeSets.get(ranChangeSets.size() - 1).getId(), changeSets.get(changeSets.size() - 1).getId());
logger.fine(msg);
} else {
logger.info("Updating database");
}
}
liquibase.update((Contexts) null);
}
} catch (Exception e) {
throw new RuntimeException("Failed to update database", e);
}
logger.fine("Completed database update");
}
代码示例来源:origin: stackoverflow.com
public void verify(DataSource ds) {
boolean throwException = false;
Contexts contexts = new Contexts("");
for(LiquibaseConfiguration c : configs) {
try(Connection con = ds.getConnection()) {
Database db = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(con));
db.setDatabaseChangeLogLockTableName(c.changeLogLockTableName());
db.setDatabaseChangeLogTableName(c.changeLogTableName());
Liquibase liquibase = new ShureviewNonCreationLiquibase(c.liquibaseResource(), new ClassLoaderResourceAccessor(), db);
liquibase.getLog();
liquibase.validate();
List<ChangeSet> listUnrunChangeSets = liquibase.listUnrunChangeSets(contexts, new LabelExpression());
if(!listUnrunChangeSets.isEmpty()) {
StringWriter writer = new StringWriter();
liquibase.update(contexts, writer);
liquibase.futureRollbackSQL(writer);
log.warn(writer.toString());
throwException = true;
}
} catch (SQLException | LiquibaseException e) {
throw new RuntimeException("Failed to verify database.", e);
}
}
if(throwException){
throw new RuntimeException("Unrun changesets in chengelog.");
}
}
代码示例来源:origin: org.keycloak/keycloak-connections-jpa-liquibase
Liquibase liquibase = getLiquibase(connection, defaultSchema);
List<ChangeSet> changeSets = liquibase.listUnrunChangeSets((Contexts) null);
if (!changeSets.isEmpty()) {
if (changeSets.get(0).getId().equals(FIRST_VERSION)) {
代码示例来源:origin: org.everit.osgi/org.everit.osgi.liquibase.component
new Liquibase(changeLogFile, new OSGiResourceAccessor(bundle), database);
List<ChangeSet> unrunChangeSets = liquibase.listUnrunChangeSets((String) null);
代码示例来源:origin: org.everit.persistence/org.everit.persistence.liquibase.ecm
new Liquibase(changeLogFile, new OSGiResourceAccessor(bundle), database);
List<ChangeSet> unrunChangeSets = liquibase.listUnrunChangeSets((String) null);
代码示例来源:origin: stackoverflow.com
liquibase.getLog();
liquibase.validate();
List<ChangeSet> listUnrunChangeSets = liquibase.listUnrunChangeSets(contexts, new LabelExpression());
代码示例来源:origin: vmware/admiral
private static void update(DataSource ds, String changeLogFile,
ResourceAccessor resourceAccessor) throws Exception {
// TODO: workaround to resolve locking issue with postgres
checkLiquibaseTables(ds);
try (Connection conn = ds.getConnection()) {
Contexts contexts = new Contexts("");
LabelExpression labels = new LabelExpression();
Liquibase liquibase = new Liquibase(changeLogFile, resourceAccessor,
new JdbcConnection(conn));
// Check if update is needed without locking liquibase tables
List<ChangeSet> changes = liquibase.listUnrunChangeSets(contexts, labels);
if (changes.isEmpty()) {
return;
}
// Release locks on timeout
releaseLockOnTimeout(liquibase);
// Reset liquibase as it has cached the run change sets during the
// listUnrunChangeSets() call which happens before acquiring the update lock and may
// miss latest entries
ChangeLogHistoryServiceFactory.getInstance().resetAll();
// Update
liquibase.update(contexts, labels);
}
}
代码示例来源:origin: com.peterphi.std.guice/stdlib-guice-liquibase
List<ChangeSet> unrun = liquibase.listUnrunChangeSets(new Contexts(contexts), new LabelExpression(labels));
代码示例来源:origin: liimaorg/liima
@Test
public void shouldNotHaveAnyOpenChangeSets() throws LiquibaseException, SQLException, ClassNotFoundException, IOException {
// given
EntityManagerProducerIntegrationTestImpl.copyIntegrationTestDB("amwFileDbIntegrationOpenChangeSets.h2.db");
Class.forName("org.h2.Driver");
conn = DriverManager.getConnection("jdbc:h2:file:../AMW_business/src/test/resources/integration-test/testdb/amwFileDbIntegrationOpenChangeSets", "sa", "");
database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(conn));
Liquibase liquibase = new Liquibase("liquibase/auto.db.changelog.xml", new ClassLoaderResourceAccessor(), database);
//when
//liquibase.changeLogSync(new Contexts(), new LabelExpression());
List<ChangeSet> unrunChangeSets = liquibase.listUnrunChangeSets(new Contexts(), new LabelExpression());
// if there are open Changesets apply them and look for errors
if(unrunChangeSets.size()>0){
try {
liquibase.update(new Contexts(), new LabelExpression());
}catch (LiquibaseException e){
fail("There are open Database Changesets on the local H2 Database, which fail when you apply them, you need to fix that and apply them afterwards with: AMW_db_scripts/update_h2_test_db.sh");
}finally {
if(conn !=null) {
conn.close();
}
}
fail("There are open Database Changesets on the local H2 Database, that can be applied without error, run AMW_db_scripts/update_h2_test_db.sh to apply them directly");
}
if(conn !=null) {
conn.close();
}
}
内容来源于网络,如有侵权,请联系作者删除!