liquibase.resource.FileSystemResourceAccessor Java Examples
The following examples show how to use
liquibase.resource.FileSystemResourceAccessor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MigrationsRunner.java From flux with Apache License 2.0 | 6 votes |
public void migrate(String dbName) { try { Configuration configuration = yamlConfiguration.subset(dbName + ".Hibernate"); Properties properties = new Properties(); properties.put("user", configuration.getProperty("hibernate.connection.username")); properties.put("password", configuration.getProperty("hibernate.connection.password")); Class.forName("com.mysql.jdbc.Driver").newInstance(); String url = (String) configuration.getProperty("hibernate.connection.url"); java.sql.Connection connection = DriverManager.getConnection(url, properties); Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection)); ClassLoader classLoader = getClass().getClassLoader(); File file = new File(classLoader.getResource(dbName + "/migrations.xml").getFile()); Liquibase liquibase = new Liquibase(file.getCanonicalPath(), new FileSystemResourceAccessor(), database); liquibase.update(new Contexts()); } catch (Exception e) { System.err.println("Unable to perform database migration."); e.printStackTrace(); } }
Example #2
Source File: ModelDBHibernateUtil.java From modeldb with Apache License 2.0 | 5 votes |
private static void createTablesLiquibaseMigration(MetadataSources metaDataSrc) throws LiquibaseException, SQLException, InterruptedException { // Get database connection try (Connection con = metaDataSrc.getServiceRegistry().getService(ConnectionProvider.class).getConnection()) { JdbcConnection jdbcCon = new JdbcConnection(con); // Overwrite default liquibase table names by custom GlobalConfiguration liquibaseConfiguration = LiquibaseConfiguration.getInstance().getConfiguration(GlobalConfiguration.class); liquibaseConfiguration.setDatabaseChangeLogLockWaitTime(1L); // Initialize Liquibase and run the update Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(jdbcCon); String rootPath = System.getProperty(ModelDBConstants.userDir); rootPath = rootPath + "\\src\\main\\resources\\liquibase\\db-changelog-1.0.xml"; Liquibase liquibase = new Liquibase(rootPath, new FileSystemResourceAccessor(), database); boolean liquibaseExecuted = false; while (!liquibaseExecuted) { try { liquibase.update(new Contexts(), new LabelExpression()); liquibaseExecuted = true; } catch (LockException ex) { LOGGER.warn( "ModelDBHibernateUtil createTablesLiquibaseMigration() getting LockException ", ex); releaseLiquibaseLock(metaDataSrc); } } } }
Example #3
Source File: SingularityCuratorTestBase.java From Singularity with Apache License 2.0 | 5 votes |
@BeforeAll public void setup() throws Exception { JerseyGuiceUtils.reset(); singularityTestModule = new SingularityTestModule(useDBTests, customConfigSetup); singularityTestModule.getInjector().injectMembers(this); singularityTestModule.start(); leaderCacheCoordinator.activateLeaderCache(); configuration.setThreadpoolShutdownDelayInSeconds(0); if (useDBTests) { Handle handle = dbiProvider.get().open(); handle.getConnection().setAutoCommit(true); 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(); handle.close(); } catch (Throwable t) {} } }
Example #4
Source File: MigratorTest.java From aerogear-unifiedpush-server with Apache License 2.0 | 4 votes |
private void initResourceAccessor() { String baseDir = "target/classes/liquibase"; resourceAccessor = new FileSystemResourceAccessor(baseDir); }
Example #5
Source File: LiquibaseModule.java From hmdm-server with Apache License 2.0 | 2 votes |
/** * <p>Gets the resource accessor to be uused for loading the change log file.</p> * * @return a resource accessor for change log file. */ @Override protected ResourceAccessor getResourceAccessor() { return new FileSystemResourceAccessor(); }