JAVA-28932 Upgrade flyway-repair to Spring boot3 migration
This commit is contained in:
parent
8fcec3fcda
commit
0e41d622ad
|
@ -10,9 +10,9 @@
|
|||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<artifactId>parent-boot-3</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-2</relativePath>
|
||||
<relativePath>../../parent-boot-3</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@ -74,7 +74,10 @@
|
|||
|
||||
<properties>
|
||||
<flyway.configFiles>src/main/resources/application-${spring-boot.run.profiles}.properties</flyway.configFiles>
|
||||
<flyway-maven-plugin.version>10.2.0</flyway-maven-plugin.version>
|
||||
<flyway-maven-plugin.version>10.4.0</flyway-maven-plugin.version>
|
||||
<java.version>17</java.version>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,38 @@
|
|||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.baeldung.flywaycallbacks.FlywayApplication;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration(classes = { FlywayApplication.class })
|
||||
public class FlywayAppIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Test
|
||||
public void testAllMigrationsExecuted() throws SQLException {
|
||||
DatabaseMetaData metadata = dataSource.getConnection()
|
||||
.getMetaData();
|
||||
ResultSet resultSet = metadata.getTables(null, null, null, new String[] { "TABLE" });
|
||||
Set<String> tables = Set.of("TABLE_ONE", "TABLE_TWO", "TABLE_THREE", "TABLE_FOUR");
|
||||
int migrations = 0;
|
||||
while (resultSet.next()) {
|
||||
if (tables.contains(resultSet.getString("TABLE_NAME"))) {
|
||||
migrations++;
|
||||
}
|
||||
}
|
||||
Assert.assertEquals(migrations, 4);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue