liquibase.Liquibase.update()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(340)

本文整理了Java中liquibase.Liquibase.update()方法的一些代码示例,展示了Liquibase.update()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Liquibase.update()方法的具体详情如下:
包路径:liquibase.Liquibase
类名称:Liquibase
方法名:update

Liquibase.update介绍

暂无

代码示例

代码示例来源:origin: dropwizard/dropwizard

@Override
@SuppressWarnings("UseOfSystemOutOrSystemErr")
public void run(Namespace namespace, Liquibase liquibase) throws Exception {
  final String context = getContext(namespace);
  final Integer count = namespace.getInt("count");
  final boolean dryRun = namespace.getBoolean("dry-run") == null ? false : namespace.getBoolean("dry-run");
  if (count != null) {
    if (dryRun) {
      liquibase.update(count, context, new OutputStreamWriter(outputStream, StandardCharsets.UTF_8));
    } else {
      liquibase.update(count, context);
    }
  } else {
    if (dryRun) {
      liquibase.update(context, new OutputStreamWriter(outputStream, StandardCharsets.UTF_8));
    } else {
      liquibase.update(context);
    }
  }
}

代码示例来源:origin: signalapp/Signal-Server

@Override
@SuppressWarnings("UseOfSystemOutOrSystemErr")
public void run(Namespace namespace, Liquibase liquibase) throws Exception {
 final String context = getContext(namespace);
 final Integer count = namespace.getInt("count");
 final Boolean dryRun = namespace.getBoolean("dry-run");
 if (count != null) {
  if (dryRun) {
   liquibase.update(count, context, new OutputStreamWriter(System.out, Charsets.UTF_8));
  } else {
   liquibase.update(count, context);
  }
 } else {
  if (dryRun) {
   liquibase.update(context, new OutputStreamWriter(System.out, Charsets.UTF_8));
  } else {
   liquibase.update(context);
  }
 }
}

代码示例来源:origin: stackoverflow.com

java.sql.Connection c = YOUR_CONNECTION;
 Liquibase liquibase = null;
 try {
   Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(c))
   liquibase = new Liquibase(YOUR_CHANGELOG, new FileSystemResourceAccessor(), database);
   liquibase.update();
 } catch (SQLException e) {
   throw new DatabaseException(e);
 } finally {
   if (c != null) {
     try {
       c.rollback();
       c.close();
     } catch (SQLException e) {
       //nothing to do
     }
   }
 }

代码示例来源:origin: traccar/traccar

private void initDatabaseSchema() throws SQLException, LiquibaseException {
  if (config.hasKey("database.changelog")) {
    ResourceAccessor resourceAccessor = new FileSystemResourceAccessor();
    Database database = DatabaseFactory.getInstance().openDatabase(
        config.getString("database.url"),
        config.getString("database.user"),
        config.getString("database.password"),
        config.getString("database.driver"),
        null, null, null, resourceAccessor);
    Liquibase liquibase = new Liquibase(
        config.getString("database.changelog"), resourceAccessor, database);
    liquibase.clearCheckSums();
    liquibase.update(new Contexts());
  }
}

代码示例来源:origin: openmrs/openmrs-core

public void upgrade(String filename) throws IOException, SQLException {
  try {
    Liquibase liquibase = new Liquibase(filename, new ClassLoaderResourceAccessor(getClass()
        .getClassLoader()), liqubaseConnection);
    liquibase.update(null);
    
    connection.commit();
  }
  catch (LiquibaseException e) {
    throw new IOException(e);
  }
}

代码示例来源:origin: HubSpot/Singularity

@Before
public void createTestData() throws Exception {
 Handle handle = dbiProvider.get().open();
 Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(handle.getConnection()));
 Liquibase liquibase = new Liquibase("singularity_test.sql", new FileSystemResourceAccessor(), database);
 liquibase.update((String) null);
 try {
  database.close();
 } catch (Throwable t) {
 }
 handle.close();
}

代码示例来源:origin: stackoverflow.com

private void migrate(){
  DataSourceFactory dataSourceFactory = RULE.getConfiguration().dataSourceFactory;
  Properties info = new Properties();
  info.setProperty("user", dataSourceFactory.getUser());
  info.setProperty("password", dataSourceFactory.getPassword());
  org.h2.jdbc.JdbcConnection h2Conn = new org.h2.jdbc.JdbcConnection(dataSourceFactory.getUrl(), info);
  JdbcConnection conn = new JdbcConnection(h2Conn);
  Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(conn);
  Liquibase liquibase = new Liquibase("migrations.xml", new ClassLoaderResourceAccessor(), database);
  String ctx = null;
  liquibase.update(ctx);
}

代码示例来源:origin: org.liquibase/liquibase-maven-plugin

@Override
protected void doUpdate(Liquibase liquibase) throws LiquibaseException {
 if (changesToApply > 0) {
  liquibase.update(changesToApply, new Contexts(contexts), new LabelExpression(labels), outputWriter);
 } else {
  liquibase.update(toTag, new Contexts(contexts), new LabelExpression(labels), outputWriter);
 }
}

代码示例来源:origin: org.liquibase/liquibase-maven-plugin

@Override
 protected void doUpdate(Liquibase liquibase) throws LiquibaseException {
  if (changesToApply > 0) {
   liquibase.update(changesToApply, new Contexts(contexts), new LabelExpression(labels));
  } else {
   liquibase.update(toTag, new Contexts(contexts), new LabelExpression(labels));
  }
 }
}

代码示例来源:origin: org.aktin/broker-server

/**
 * Perform liquibase update operation
 * @see Liquibase#update(Contexts, LabelExpression)
 * @throws LiquibaseException liquibase error
 */
public void update() throws LiquibaseException{
  liquibase.update(new Contexts(), new LabelExpression());
}
public void reset() throws LiquibaseException{

代码示例来源:origin: org.liquibase/liquibase-maven-plugin

@Override
protected void doUpdate(Liquibase liquibase) throws LiquibaseException {
  if (changesToApply > 0) {
    liquibase.update(changesToApply, new Contexts(contexts), new LabelExpression(labels), outputWriter);
  } else {
    liquibase.update(toTag, new Contexts(contexts), new LabelExpression(labels), outputWriter);
  }
}

代码示例来源:origin: stackoverflow.com

// Create the test database with the LiquiBase migrations.
@BeforeClass
public static void up() throws Exception
{
  ManagedDataSource ds = RULE.getConfiguration().getMainDataSource().build(
    RULE.getEnvironment().metrics(), "migrations");
  try (Connection connection = ds.getConnection())
  {
    Liquibase migrator = new Liquibase("migrations.xml", new ClassLoaderResourceAccessor(), new JdbcConnection(connection));
    migrator.update("");
  }
}

代码示例来源:origin: org.liquibase/liquibase-maven-plugin

@Override
protected void doUpdate(Liquibase liquibase) throws LiquibaseException {
  if (dropFirst) {
   liquibase.dropAll();
  }
 if (changesToApply > 0) {
  liquibase.update(changesToApply, new Contexts(contexts), new LabelExpression(labels));
 } else {
  liquibase.update(toTag, new Contexts(contexts), new LabelExpression(labels));
 }
}

代码示例来源:origin: org.flowable/flowable-form-engine

@Override
public void schemaCreate() {
  Liquibase liquibase = createLiquibaseInstance();
  try {
    liquibase.update("form");
  } catch (Exception e) {
    throw new FlowableException("Error creating form engine tables", e);
  } finally {
    closeDatabase(liquibase);
  }
}

代码示例来源:origin: org.flowable/flowable-content-engine

@Override
public void schemaCreate() {
  Liquibase liquibase = createLiquibaseInstance(CommandContextUtil.getContentEngineConfiguration());
  try {
    liquibase.update("content");
  } catch (Exception e) {
    throw new FlowableException("Error creating content engine tables", e);
  } finally {
    closeDatabase(liquibase);
  }
}

代码示例来源:origin: org.flowable/flowable-dmn-engine

@Override
public void schemaCreate() {
  Liquibase liquibase = null;
  try {
    liquibase = createLiquibaseInstance(CommandContextUtil.getDmnEngineConfiguration());
    liquibase.update("dmn");
  } catch (Exception e) {
    throw new FlowableException("Error creating DMN engine tables", e);
  } finally {
    closeDatabase(liquibase);
  }
}

代码示例来源:origin: OpenClinica/OpenClinica

protected void performUpdate(Liquibase liquibase) throws LiquibaseException {
  if (this.tag != null) {
    liquibase.update(this.tag, new Contexts(this.getContexts()), new LabelExpression(this.getLabels()));
  } else {
    liquibase.update(new Contexts(this.getContexts()), new LabelExpression(this.getLabels()));
  }
}

代码示例来源:origin: com.walmartlabs.concord.server/concord-server-db

private static void migrateDb(Connection conn, String logPath, String logTable, String lockTable) throws Exception {
  LogFactory.getInstance().setDefaultLoggingLevel(LogLevel.WARNING);
  Database db = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(conn));
  db.setDatabaseChangeLogTableName(logTable);
  db.setDatabaseChangeLogLockTableName(lockTable);
  Liquibase lb = new Liquibase(logPath, new ClassLoaderResourceAccessor(), db);
  lb.update((String) null);
}

代码示例来源:origin: com.hubspot/BlazarData

private static void initializeEmptyTables() throws Exception {
 try (Connection connection = getConnection()) {
  ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor();
  JdbcConnection jdbcConnection = new JdbcConnection(connection);
  Liquibase liquibase = new Liquibase("schema.sql", resourceAccessor, jdbcConnection);
  liquibase.update(new Contexts());
 }
}

代码示例来源:origin: com.hubspot/SingularityService

@Before
public void createTestData() throws Exception {
 Handle handle = dbiProvider.get().open();
 Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(handle.getConnection()));
 Liquibase liquibase = new Liquibase("singularity_test.sql", new FileSystemResourceAccessor(), database);
 liquibase.update((String) null);
 try {
  database.close();
 } catch (Throwable t) {
 }
 handle.close();
}

相关文章