The traditional way to do that is to create scripts for each database change , store them in a file and fire them in the environment you want to migra

How to automate database migration in Spring Boot using flywaydb?

submited by
Style Pass
2021-05-20 14:48:42

The traditional way to do that is to create scripts for each database change , store them in a file and fire them in the environment you want to migrate to.

You just need to place your scripts in a folder with version number and the latest version will be automatically executed when your spring boot application starts!

Let’s say you created a new table and inserted a record in your development database and you want to migrate these changes to another database.

table: schema_version – this property is used to indicate the table which will be used to maintain the version of your scripts.

Every time your application starts , only the latest version of your script will be run and this is done by storing the versions in the table you specify here (the default and standard name used is schema_version)

This naming convention is important . Flyway looks for it. It stores the executed version in the table schema_version so that the next time you start your application flyway will refer this table and skip the already run versions and run only the latest version in your project.

Leave a Comment