@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); } } }
@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); } } }
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 } } }
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()); } }
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); } }
@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(); }
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); }
@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); } }
/** * 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{
@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); } }
// 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(""); } }
@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)); } }
@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); } }
@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); } }
@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); } }
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())); } }
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); }
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()); } }
@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(); }