Member-only story
Flyway — Version control for your database
What it is?
Flyway is an open-source database migration tool. It strongly favors simplicity and convention over configuration.
It is based around just 7 basic commands: Migrate, Clean, Info, Validate, Undo, Baseline and Repair.
We can use Flyway to maintain and organize our SQL scripts of an Application. Lets see in practice.
In this article we will focuses on Java and Maven implementation, but Flyway also supports Gradle and command line tool.
How to install
For java, we should add the core dependency (in pom.xml or classpath), and this will enable us to use the API:
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>8.2.0</version>
</dependency>
For the Maven Plugin, we should use:
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>8.2.0</version>
<configuration>
<url>jdbc_url</url>
<user>database_user</user>
<password>database_password</password>
</configuration>
</plugin>
For the configurations of the database, alternatively we could add a separate .conf file that will hold this values: