Java Code Examples for org.flywaydb.core.Flyway#setSqlMigrationPrefix()
The following examples show how to use
org.flywaydb.core.Flyway#setSqlMigrationPrefix() .
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: SchemaFlywayFactory.java From registry with Apache License 2.0 | 6 votes |
private static Flyway basicFlyway(StorageProviderConfiguration conf, String scriptRootPath, boolean validateOnMigrate) { Flyway flyway = new Flyway(); String location = "filesystem:" + scriptRootPath + File.separator + conf.getDbType(); flyway.setEncoding(encoding); flyway.setTable(metaDataTableName); flyway.setSqlMigrationPrefix(sqlMigrationPrefix); flyway.setValidateOnMigrate(validateOnMigrate); flyway.setOutOfOrder(outOfOrder); flyway.setBaselineOnMigrate(baselineOnMigrate); flyway.setBaselineVersion(MigrationVersion.fromVersion(baselineVersion)); flyway.setCleanOnValidationError(cleanOnValidationError); flyway.setLocations(location); return flyway; }
Example 2
Source File: CMSMigrations.java From StubbornJava with MIT License | 5 votes |
public static void migrate() { Flyway flyway = new Flyway(); flyway.setDataSource(CMSConnectionPools.processing()); flyway.setBaselineOnMigrate(true); flyway.setLocations("db/cms/migration"); flyway.setSqlMigrationPrefix("V_"); flyway.setTable("_flyway"); flyway.migrate(); }
Example 3
Source File: CMSMigrations.java From StubbornJava with MIT License | 5 votes |
public static void migrate() { Flyway flyway = new Flyway(); flyway.setDataSource(CMSConnectionPools.processing()); flyway.setBaselineOnMigrate(true); flyway.setLocations("db/cms/migration"); flyway.setSqlMigrationPrefix("V_"); flyway.setTable("_flyway"); flyway.migrate(); }
Example 4
Source File: FlywaySchemaInitializer.java From che with Eclipse Public License 2.0 | 5 votes |
@Override public Map<String, String> init() throws SchemaInitializationException { final Map<String, String> initResult = new HashMap<>(); try (final Connection conn = dataSource.getConnection()) { final Flyway flyway = new Flyway(); flyway.setDataSource(dataSource); flyway.setLocations(locations); flyway.setClassLoader(Thread.currentThread().getContextClassLoader()); final DbSupport dbSupport = DbSupportFactory.createDbSupport(conn, true); final MetaDataTable mt = new MetaDataTableImpl( dbSupport, dbSupport.getOriginalSchema().getTable(flyway.getTable()), flyway.getInstalledBy()); initResult.put(BARE_DB_INIT_PROPERTY_NAME, String.valueOf(!mt.hasAppliedMigrations())); final String productName = conn.getMetaData().getDatabaseProductName().toLowerCase(); flyway.setResolvers( new CustomSqlMigrationResolver(productName, dbSupport, placeholderReplacer)); flyway.setSkipDefaultResolvers(true); flyway.setBaselineOnMigrate(baselineOnMigrate); if (baselineOnMigrate) { flyway.setBaselineVersionAsString(baselineVersion); } flyway.setSqlMigrationSeparator(versionSeparator); flyway.setSqlMigrationSuffix(scriptsSuffix); flyway.setSqlMigrationPrefix(scriptsPrefix); flyway.migrate(); } catch (SQLException | RuntimeException x) { throw new SchemaInitializationException(x.getLocalizedMessage(), x); } return initResult; }
Example 5
Source File: DataSourceAppConfig.java From logsniffer with GNU Lesser General Public License v3.0 | 4 votes |
/** * @return H2 pooled data source * @throws SQLException */ @Bean(destroyMethod = "dispose") public DataSource dataSource() throws SQLException { final JdbcConnectionPool pool = JdbcConnectionPool.create(url, user, password); pool.setMaxConnections(maxPoolConnections); Connection con = null; con = pool.getConnection(); final Flyway flyway = new Flyway(); flyway.setLocations("classpath:sql/migration"); flyway.setDataSource(pool); flyway.setSqlMigrationPrefix("VOS-"); flyway.setIgnoreFailedFutureMigration(true); final JdbcTemplate tpl = new JdbcTemplate(pool); if (tpl.queryForObject("select count(*) from information_schema.tables where table_name = 'LOG_SOURCES'", int.class) == 0) { logger.info("H2 database not found, creating new schema and populate with default data"); flyway.setBaselineVersion(MigrationVersion.fromVersion(DB_SETUP_VERSION)); flyway.setBaselineOnMigrate(true); try { final ResourceDatabasePopulator dbPopulator = new ResourceDatabasePopulator(); dbPopulator.addScript(new ClassPathResource("/sql/quartz/tables_h2.sql")); dbPopulator.addScript(new ClassPathResource("/sql/model/schema_h2.sql")); dbPopulator.populate(con); newSchema = true; logger.info("Established H2 connection pool with new database"); } finally { if (con != null) { con.close(); } } } else { logger.info("Established H2 connection pool with existing database"); if (tpl.queryForObject("select count(*) from information_schema.tables where table_name = 'schema_version'", int.class) == 0) { logger.info("Flyway's DB migration not setup in this version, set baseline version to 0.5.0"); flyway.setBaselineVersion(MigrationVersion.fromVersion("0.5.0")); flyway.setBaselineOnMigrate(true); } } logger.debug("Migrating database, base version is: {}", flyway.getBaselineVersion()); flyway.migrate(); logger.debug("Database migrated from base version: {}", flyway.getBaselineVersion()); return pool; }