org.flywaydb.core.Flyway.migrate()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(272)

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

Flyway.migrate介绍

暂无

代码示例

代码示例来源:origin: jooby-project/jooby

  1. @Override
  2. public void run(final Flyway flyway) {
  3. flyway.migrate();
  4. }
  5. },

代码示例来源:origin: apache/incubator-gobblin

  1. public void migrate() throws FlywayException {
  2. flyway.migrate();
  3. }

代码示例来源:origin: Netflix/conductor

  1. private void flywayMigrate(DataSource dataSource) {
  2. boolean enabled = configuration.isFlywayEnabled();
  3. if (!enabled) {
  4. logger.debug("Flyway migrations are disabled");
  5. return;
  6. }
  7. Flyway flyway = new Flyway();
  8. configuration.getFlywayTable().ifPresent(tableName -> {
  9. logger.debug("Using Flyway migration table '{}'", tableName);
  10. flyway.setTable(tableName);
  11. });
  12. flyway.setDataSource(dataSource);
  13. flyway.setPlaceholderReplacement(false);
  14. flyway.migrate();
  15. }
  16. }

代码示例来源:origin: cloudfoundry/uaa

  1. @Test
  2. public void everyTableShouldHaveAPrimaryKeyColumn() throws Exception {
  3. flyway.migrate();
  4. List<String> tableNames = jdbcTemplate.queryForList(getAllTableNames, String.class, jdbcTemplate.getDataSource().getConnection().getCatalog());
  5. assertThat(tableNames, hasSize(greaterThan(0)));
  6. for (String tableName : tableNames) {
  7. int count = jdbcTemplate.queryForObject(checkPrimaryKeyExists, Integer.class, jdbcTemplate.getDataSource().getConnection().getCatalog(), tableName);
  8. assertThat(format("%s is missing primary key", tableName), count, greaterThanOrEqualTo(1));
  9. }
  10. }

代码示例来源:origin: cloudfoundry/uaa

  1. @Test
  2. public void everyTableShouldHaveAPrimaryKeyColumn() throws Exception {
  3. flyway.migrate();
  4. List<String> tableNames = jdbcTemplate.queryForList(getAllTableNames, String.class, jdbcTemplate.getDataSource().getConnection().getCatalog());
  5. assertThat(tableNames, hasSize(greaterThan(0)));
  6. for (String tableName : tableNames) {
  7. int count = jdbcTemplate.queryForObject(checkPrimaryKeyExists, Integer.class, jdbcTemplate.getDataSource().getConnection().getCatalog(), tableName);
  8. assertThat(format("%s is missing primary key", tableName), count, greaterThanOrEqualTo(1));
  9. }
  10. }

代码示例来源:origin: Netflix/conductor

  1. private void flywayMigrate(Configuration config, DataSource dataSource) {
  2. boolean enabled = getBool(config.getProperty("flyway.enabled", "true"), true);
  3. if(!enabled) {
  4. logger.debug("Flyway migrations are disabled");
  5. return;
  6. }
  7. String migrationTable = config.getProperty("flyway.table", null);
  8. Flyway flyway = new Flyway();
  9. if(null != migrationTable) {
  10. logger.debug("Using Flyway migration table '{}'", migrationTable);
  11. flyway.setTable(migrationTable);
  12. }
  13. flyway.setDataSource(dataSource);
  14. flyway.setPlaceholderReplacement(false);
  15. flyway.migrate();
  16. }

代码示例来源:origin: cloudfoundry/uaa

  1. public void run(MigrationTest... tests) {
  2. final int[] assertionsRan = {0};
  3. flyway.setCallbacks(new BaseFlywayCallback() {
  4. @Override
  5. public void afterEachMigrate(Connection connection, MigrationInfo info) {
  6. super.afterEachMigrate(connection, info);
  7. try {
  8. connection.commit();
  9. } catch (SQLException e) {
  10. Assert.fail(e.getMessage());
  11. }
  12. for (MigrationTest test : tests) {
  13. if (test.getTargetMigration().equals(info.getVersion().getVersion())) {
  14. try {
  15. test.runAssertions();
  16. } catch (Exception e) {
  17. Assert.fail(e.getMessage());
  18. }
  19. assertionsRan[0]++;
  20. }
  21. }
  22. }
  23. });
  24. flyway.migrate();
  25. assertThat("Not every db migration ran", assertionsRan[0], is(tests.length));
  26. }
  27. }

代码示例来源:origin: cloudfoundry/uaa

  1. @Test
  2. public void everyTableShouldHaveAPrimaryKeyColumn() throws Exception {
  3. flyway.migrate();
  4. List<String> tableNames = jdbcTemplate.queryForList(getAllTableNames, String.class, jdbcTemplate.getDataSource().getConnection().getCatalog());
  5. assertThat(tableNames, hasSize(greaterThan(0)));
  6. for (String tableName : tableNames) {
  7. int count = jdbcTemplate.queryForObject(checkPrimaryKeyExists, Integer.class, jdbcTemplate.getDataSource().getConnection().getCatalog(), tableName);
  8. assertThat(format("%s is missing primary key", tableName), count, greaterThanOrEqualTo(1));
  9. }
  10. try {
  11. jdbcTemplate.execute(insertNewOauthCodeRecord);
  12. } catch (Exception _) {
  13. fail("oauth_code table should auto increment primary key when inserting data.");
  14. }
  15. }

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

  1. @Override
  2. public void before() throws Throwable {
  3. if (migration != null) {
  4. final Flyway flyway = new Flyway();
  5. flyway.setDataSource(getDataSource());
  6. flyway.setLocations(migration.paths.toArray(new String[0]));
  7. flyway.setSchemas(migration.schemas.toArray(new String[0]));
  8. flyway.migrate();
  9. }
  10. jdbi = Jdbi.create(getDataSource());
  11. if (installPlugins) {
  12. jdbi.installPlugins();
  13. }
  14. plugins.forEach(jdbi::installPlugin);
  15. handle = jdbi.open();
  16. }

代码示例来源:origin: cloudfoundry/uaa

  1. @Test
  2. public void everyTableShouldHaveAPrimaryKeyColumn() throws Exception {
  3. flyway.migrate();
  4. List<String> tableNames = jdbcTemplate.queryForList(getAllTableNames, String.class, jdbcTemplate.getDataSource().getConnection().getCatalog());
  5. assertThat(tableNames, hasSize(greaterThan(0)));
  6. for (String tableName : tableNames) {
  7. int count = jdbcTemplate.queryForObject(checkPrimaryKeyExists, Integer.class, jdbcTemplate.getDataSource().getConnection().getCatalog(), tableName, "%" + tableName + "_pk%");
  8. assertThat(format("%s is missing primary key", tableName), count, greaterThanOrEqualTo(1));
  9. }
  10. try {
  11. jdbcTemplate.execute(insertNewOauthCodeRecord);
  12. } catch (Exception _) {
  13. fail("oauth_code table should auto increment primary key when inserting data.");
  14. }
  15. }

代码示例来源:origin: Netflix/conductor

  1. private void flywayMigrate(DataSource dataSource) {
  2. Flyway flyway = new Flyway();
  3. flyway.setDataSource(dataSource);
  4. flyway.setPlaceholderReplacement(false);
  5. flyway.migrate();
  6. }

代码示例来源:origin: Netflix/conductor

  1. private synchronized static void flywayMigrate(DataSource dataSource) {
  2. if(EmbeddedDatabase.hasBeenMigrated()) {
  3. return;
  4. }
  5. synchronized (MySQLBaseDAOTest.class) {
  6. Flyway flyway = new Flyway();
  7. flyway.setDataSource(dataSource);
  8. flyway.setPlaceholderReplacement(false);
  9. flyway.migrate();
  10. }
  11. }

代码示例来源:origin: ninjaframework/ninja

  1. @Override
  2. public void migrate() {
  3. // Get the connection credentials from application.conf
  4. String connectionUrl = ninjaProperties.getOrDie(NinjaConstant.DB_CONNECTION_URL);
  5. String connectionUsername = ninjaProperties.getOrDie(NinjaConstant.DB_CONNECTION_USERNAME);
  6. String connectionPassword = ninjaProperties.getOrDie(NinjaConstant.DB_CONNECTION_PASSWORD);
  7. // We migrate automatically => if you do not want that (eg in production)
  8. // set ninja.migration.run=false in application.conf
  9. Flyway flyway = new Flyway();
  10. flyway.setDataSource(connectionUrl, connectionUsername, connectionPassword);
  11. // In testmode we are cleaning the database so that subsequent testcases
  12. // get a fresh database.
  13. if (ninjaProperties.getBooleanWithDefault(NinjaConstant.NINJA_MIGRATION_DROP_SCHEMA,
  14. ninjaProperties.isTest() ? true : false )) {
  15. flyway.clean();
  16. }
  17. flyway.migrate();
  18. }

代码示例来源:origin: yasserg/crawler4j

  1. flyway.migrate();

代码示例来源:origin: cloudfoundry/uaa

  1. if (cleandb) {
  2. context.getBean(Flyway.class).clean();
  3. context.getBean(Flyway.class).migrate();

代码示例来源:origin: cloudfoundry/uaa

  1. @BeforeClass
  2. public static void setUpDatabase() throws Exception {
  3. EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
  4. database = builder.build();
  5. Flyway flyway = new Flyway();
  6. flyway.setBaselineVersion(MigrationVersion.fromVersion("1.5.2"));
  7. flyway.setLocations("classpath:/org/cloudfoundry/identity/uaa/db/hsqldb/");
  8. flyway.setDataSource(database);
  9. flyway.migrate();
  10. }

代码示例来源:origin: cloudfoundry/uaa

  1. @BeforeClass
  2. public static void init() {
  3. EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
  4. database = builder.build();
  5. flyway = new Flyway();
  6. flyway.setBaselineVersion(MigrationVersion.fromVersion("1.5.2"));
  7. flyway.setLocations("classpath:/org/cloudfoundry/identity/uaa/db/hsqldb/");
  8. flyway.setDataSource(database);
  9. flyway.migrate();
  10. }

代码示例来源:origin: rakam-io/rakam

  1. @Inject
  2. public FlywayExecutor(@Named("report.metadata.store.jdbc") JDBCPoolDataSource config) {
  3. Flyway flyway = new Flyway();
  4. flyway.setBaselineOnMigrate(true);
  5. flyway.setDataSource(config);
  6. flyway.setLocations("db/migration/report");
  7. flyway.setTable("schema_version_report");
  8. try {
  9. flyway.migrate();
  10. } catch (FlywayException e) {
  11. flyway.repair();
  12. }
  13. }
  14. }

代码示例来源:origin: tomoya92/pybbs

  1. @PostConstruct
  2. @DependsOn("dataSourceHelper")
  3. public void migrate() {
  4. Flyway flyway = Flyway.configure()
  5. .dataSource(dataSource)
  6. .locations("classpath:db/migration", "filesystem:db/migration")
  7. .baselineOnMigrate(true)
  8. .load();
  9. flyway.migrate();
  10. }

代码示例来源:origin: sixt/ja-micro

  1. @Test
  2. public void sleepAfterFailedMigration() {
  3. props.addProperty("databaseServer", "foo");
  4. Flyway flyway = mock(Flyway.class);
  5. when(flyway.migrate()).thenThrow(new FlywayException());
  6. migrator.flyway = flyway;
  7. migrator.flywayFailedSemaphore.release();
  8. migrator.migrate();
  9. }
  10. }

相关文章