Skip to content

ThomasJaspers/db_flyway_sample

Repository files navigation

db_flyway_sample

This is an easy example how to create database migrations with Flyway

Please note that more information is given in the related blog articles on the topic: Managing Database Migrations and Execute Migrations using Maven

It is based on PostgreSQL database and should run right away after checking it out, if your postgres-server is up and running. You might need to add password to the create- and drop-scripts depending on your database configuration for the postgres-user. Of course you can also easily switch the example to make use of another database by changing JDBC imports and URL.

As it is not possible to create a new database with Flyway this needs to be done outside of Flyway. The same is true for creating the database user that is used. To do this there are two convenience scripts:

  • createDatabaseAndUser.sh
  • dropDatabaseAndUser.sh

Execution using Maven

To execute the example just execute the create-script and then you can execute Flyway using Maven. Please take a look at the POM-file to check the Flyway configuration.

mvn clean compile flyway:migrate

Execution using the Command Line Tool

Install the Flyway Command Line Tool according to these instructions

Then execute the following command from the command line. The configuration file flyway.conf contains all the needed configuration for execution from the command line. The good thing is that Flyway already comes with JDBC drivers for a good amount of database systems including PostgreSQL. Thus there is no need to install anything in addition here.

flyway migrate

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages