private static MigrationVersion getDatabaseVersion(DataSource dataSource) throws FlywayException { Flyway flyway = new Flyway(); flyway.setDataSource(dataSource); MigrationInfoService info = flyway.info(); MigrationVersion currentVersion = MigrationVersion.EMPTY; if (info.current() != null) { currentVersion = info.current().getVersion(); } return currentVersion; }
private static MigrationVersion getDatabaseVersion(DataSource dataSource) throws FlywayException { Flyway flyway = new Flyway(); flyway.setDataSource(dataSource); MigrationInfoService info = flyway.info(); MigrationVersion currentVersion = MigrationVersion.EMPTY; if (info.current() != null) { currentVersion = info.current().getVersion(); } return currentVersion; }
private static MigrationVersion getDatabaseVersion(DataSource dataSource) throws FlywayException { Flyway flyway = new Flyway(); flyway.setDataSource(dataSource); MigrationInfoService info = flyway.info(); MigrationVersion currentVersion = MigrationVersion.EMPTY; if (info.current() != null) { currentVersion = info.current().getVersion(); } return currentVersion; }
@Override protected Object run(Flyway flyway) { MigrationInfoService info = flyway.info(); MigrationInfo current = info.current(); MigrationVersion currentSchemaVersion = current == null ? MigrationVersion.EMPTY : current.getVersion(); System.out.println("Schema version: " + currentSchemaVersion); System.out.println(MigrationInfoDumper.dumpToAsciiTable(info.all())); return null; } }
@Override public String getSchemaVersion() throws TopiaMigrationServiceException { MigrationInfo currentOrNull = flyway.info().current(); if (currentOrNull == null) { throw new TopiaMigrationServiceException("schema version is unknown"); } String schemaVersion = currentOrNull.getVersion().getVersion(); return schemaVersion; }
@Override public void migrate(Flyway flyway) { MigrationInfo current = flyway.info().current(); if (current != null && current.getVersion().equals(INITIAL) && current.getType() == MigrationType.SQL) { logger.info("Detected initial version based on SQL scripts, doing repair to switch to Java based migrations."); flyway.repair(); } flyway.migrate(); } }
switch (revision) { case "current": entity = flyway.info().current(); break; case "pending":