CloseableLiquibaseWithClassPathMigrationsFile( ManagedDataSource dataSource, Database database, String file ) throws LiquibaseException, SQLException { super(file, new ClassLoaderResourceAccessor(), database, dataSource); }
CloseableLiquibaseWithFileSystemMigrationsFile( ManagedDataSource dataSource, Database database, String file ) throws LiquibaseException, SQLException { super(file, new FileSystemResourceAccessor(), database, dataSource); }
@Override public Enumeration<URL> getResources(String packageName) throws IOException { return this.accessor.getResources(packageName); }
ResourceAccessor fsFO = new FileSystemResourceAccessor(); return new Liquibase(changeLogFile, new CompositeResourceAccessor(openmrsFO, fsFO), database);
@Override public ClassLoader toClassLoader() { // Does not appear to be used return inner.toClassLoader(); } }
try { tmpOutputFile = File.createTempFile(sqlFile, "tmp"); InputStream sqlFileInputStream = fileOpener.getResourceAsStream(sqlFile); OutputStream outputStream = new FileOutputStream(tmpOutputFile); OpenmrsUtil.copyFile(sqlFileInputStream, outputStream);
@Override public Set<String> list(final String relativeTo, final String path, final boolean includeFiles, final boolean includeDirectories, final boolean recursive) throws IOException { // Does not appear to be used return inner.list(relativeTo, path, includeFiles, includeDirectories, recursive); }
public CloseableLiquibase(ManagedDataSource dataSource, String migrations) throws LiquibaseException, ClassNotFoundException, SQLException { super(migrations, new ClassLoaderResourceAccessor(), new JdbcConnection(dataSource.getConnection())); this.dataSource = dataSource; }
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 } } }
/** * 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 ClassLoader toClassLoader() { return this.accessor.toClassLoader(); } }
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); } }
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()); } }
@Override public ClassLoader toClassLoader() { // Does not appear to be used return inner.toClassLoader(); } }
@Override public ResourceAccessor create() { return new ClassLoaderResourceAccessor(); } }
CloseableLiquibaseWithFileSystemMigrationsFile( ManagedDataSource dataSource, Database database, String file ) throws LiquibaseException, SQLException { super(file, new FileSystemResourceAccessor(), database, dataSource); }
CloseableLiquibaseWithClassPathMigrationsFile( ManagedDataSource dataSource, Database database, String file ) throws LiquibaseException, SQLException { super(file, new ClassLoaderResourceAccessor(), database, dataSource); }
/** * API method. */ public ResourceAccessor createResourceAccessor() { return new FileSystemResourceAccessor(ROOT_PATH); }
/** * A reference to the changelog file. Can be in any format supported by liquibase (currently SQL,Yaml,XML or JSON) * * @param resource a resource that will be read from classpath using Class.getResource(String) * @return the same builder */ public Builder withChangelogResource(final String resource) { this.databaseChangeLog = resource; this.resourceAccessor = new ClassLoaderResourceAccessor(); return this; }
@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(); }