What Is Flyway
Flyway is an open-source tool, licensed under Apache License 2.0 and a commercial license, that helps you implement automated and version-based database migrations. 1 It allows you to define the required update operations in an SQL script or as Java code. You can then run the migration from a command line client or automatically as part of your build process or integrated into your Java application. The good thing about this process is that Flyway detects the required update operations and executes them. So, you don’t need to know which SQL update statements need to be performed to update your current database. You and your co- workers just define the update operations to migrate the database from one version to the next. And Flyway detects the current version and performs the necessary update operations to get the database to the latest version. To be able to do that, Flyway uses a metadata table to document the current database version and all executed updates. By default, this table is called SCHEMA_VERSION. OK, enough theory. Let’s implement the first automated database migration with Flyway. 2 As described earlier, you can use SQL scripts or Java classes to define your database migration. In most cases, you should define all migration steps in an SQL script. But if you need to implement complex migrations, e.g., read information from a BLOB and store it in a new set of columns, you can do that in Java. Let’s stick to the most common approach and use the following SQL statements to create a small database.
[Show full text]