Top Flyway Interview Questions (2023) | CodeUsingJava
















Most frequently Asked Flyway Interview Questions


  1. What is Flyway?
  2. What are the name convention used in Flyway?
  3. What are Flyway Migration Tools?
  4. How do we implement Complex Migrations?
  5. How can we integrating Spring Boot by underscores Flyway?
  6. Can multiple nodes migrate in parallel in Flyway?
  7. How can we configure Flyway Database?
  8. How can we disable Flyway in a Spring profile?
  9. How do we create a database with Flyway?
  10. How can we log-in Flyway SQL with Spring Boot?
  11. How does Flyway handles multiple databases?

What is Flyway?

Flyway is used for checking the version of the database and in applying migrations before the application starts. When the developer needs to change the database or for issuing changes to the data that is residing on it. We need to create a SQL Script by following the name convention in the directory.

What are the name convention used in Flyway?

Flyway Interview Questions
Flyway name convention consists of:
Prefix - acts as default to V.
Version - used in separating dots or underscores as part as one likes.
Separator - helps in separating version from the Description.
Description - helps in separating underscores, spaces, etc.
Suffix - acts as default to .sql.

What are Flyway Migration Tools?

Flyway Interview Questions

How do we implement Complex Migrations?

Flytway can find and execute migration classes.We need to implement Jdbc Migration Interface and add it to our class for the package which is defined in Flyways location property and use the class name which follows Flyways Naming Schema.
public class V2_migration implement JdbcMigration{
@Override
public void migrate(Connection) throws
Exception{
     //need to implement our migration here..
}
}


How can we integrating Spring Boot bu underscores Flyway?

For integrating Spring Boot using Flyway, we need to add flyway-core to our application.We can also add another dependencies such as hsqldb.
HSQLDB is a memory database which is written in Java.Which easily integrates with Spring.
<?xml version="1.0" encoding="UTF-8"?>
<project ...>
<!-- everything else -->
<dependencies>
 <!-- other dependencies -->
<dependency>
 <groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
 <artifactId>hsqldb</artifactId>
 <version>2.3.3</version>
</dependency>
</dependencies>
<!-- everything else -->
</project>


Can multiple nodes migrate in parallel in Flyway?

Yes
Flyway is used for locking the technology of our database for coordinating multiple nodes. It also helps in ensuring if there are any multiple instances in our application that may attempt to migrate the database at the same time. It also supports Cluster Configuration.

How can we configure Flyway Database?

We can configure Flyway Database by using:
Spring Boot Starter Web
Flyway
MySQL
JDBC

How can we disable Flyway in a Spring profile?

We can disable Flyway by using:
application.properties format:
spring.flyway.enabled=false

application.yml format:
spring:
    flyway:
        enabled: false


How do we create a database with Flyway?

We can create a database by using the following command:
PGPASSWORD='567' psql -U postgres -f migration/V1__initDB.sql


How can we log-in Flyway SQL with Spring Boot?

We can log-in Flyway SQL with Spring Boot by using the following command:
<logger name="org.flywaydb.core.internal.dbsupport.SqlScript" level="DEBUG"/>


How does Flyway handles multiple databases?

Flyway handles multiple databases by using the following command:
<project xmlns="
xmlns:xsi="
xsi:schemaLocation="

  <modelVersion>4.0.0</modelVersion>
  <groupId>com.test</groupId>
  <artifactId>test</artifactId>
  <version>0.0.1-SNAPSHOT</version>


  <build>
        <plugins>
            <!-- Flyway plugin configuration -->
            <plugin>
                <groupId>org.flywaydb</groupId>
                <artifactId>flyway-maven-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <url>jdbc:mysql://localhost:3306/argentina</url>
                    <user>test</user>
                <password>test</password>
                </configuration>
                <dependencies>
                    <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>5.1.21</version>
            </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

  <dependencies>
        <dependency>
              <!-- alllll my dependency list -->
        </dependency>

        <!-- DB dependencies -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.21</version>
        </dependency>

  </dependencies>
</project>