What is Flyway and when to use it?

The system recently drew attention to this question, and it talks about Flyway.

So I would like to know:

  • What is Flyway?
  • What problems does he propose to heal?
  • when to use it?
  • What are the competing solutions?
  • does it fit for multi-tenancy? if so, for heterogeneous scheme banks, does it also fit?
Author: Dherik, 2018-02-19

1 answers

What is Flyway?

Flyway is one of several tools that propose to bring order and organization to the SQL scripts that are executed in the database, functioning as a version control of the same.

What problems does he propose to heal?

A tool like this allows:

  • synchronize the database with the application version;
  • Know which SQL scripts were executed or No;
  • automate script execution;
  • create a database from scratch;
  • allows you to create a rollback of changes in the database (useful in rare cases).

When to use it?

I believe it is a valid option for projects of any size. Since they are often tools that are easy to set up and use, I do not see many reasons to give it up, as it brings with it several advantages.

It can be dispensable in some projects where DBAs are involved and these prefer to control SQL scripts applied outside the application.

What are the competing solutions?

Flyway is a tool aimed at the Java ecosystem. There are other alternatives that also work with Java but are independent of the language, such as Liquibase , which brings some interesting features to the best .

In the C# ecosystem I have already had the opportunity to use successfully the FluentMigrator . Currently, this type of tool is quite common and each ecosystem provides some alternative.

Does it fit for multi-tenancy? if so, for heterogeneous scheme banks, does it also fit?

Yes, for the two questions .

If the schemas are identical and there is one per tenant , you simply iterate through each existing schema and run the Flyway on each one. If they all have identical schemes, there will be a single History table that will be in the first schema in the list of supported schemas.

If the schemas of each tenant are different, even with distinct lifecycles, you can still use Flyway to control them, keeping multiple instances of Flyway and allowing each instance to manage its schema and history.

 5
Author: Dherik, 2018-09-27 03:40:46