Flyway Migrations
Control Center provides a simple way to set up Flyway migrations to initialize your database. This guide walks you through the steps to configure Flyway migrations for your Vaadin application using Control Center.
Control Center Starter
Adding the Control Center Starter to your project dependencies brings in the Flyway dependency. This allows you to manage your database migrations easily. If you haven’t already done so, add the Control Center Starter to your project.
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>control-center-starter</artifactId>
</dependency>
Once this dependency is added, any migrations you create are automatically detected and applied to your database when the application starts.
Note
|
If you want to use the Control Center Starter without Flyway migrations, you can disable them by setting the
|
Migration Files
Flyway migrations are SQL scripts that define the changes to be applied to your database schema. These scripts should be placed in the src/main/resources/db/migration
directory of your project. The naming convention for migration files is V<version>__<description>.sql
, where <version>
is a version number and <description>
is a brief description of the migration.
For example, a migration file to create a users
table might be named V1__Create_users_table.sql
. The contents of the file could look like this:
CREATE TABLE users (
id SERIAL PRIMARY KEY,
username VARCHAR(50) NOT NULL,
password VARCHAR(50) NOT NULL
);
INSERT INTO users (username, password) VALUES ('admin', 'admin');
You can create multiple migration files, and Flyway applies them in order based on their version numbers. Ideally, each migration file should contain a single change to the database schema, such as creating a table, adding a column, or modifying data.
More information about Flyway migration files can be found in the Flyway documentation.
Viewing Migration Status
If you have enabled the Database feature, you can view the status of your Flyway migrations in the Control Center UI.
To view the details of the applied migrations, first select the relevant application from the Application Selector, as shown in the screenshot here.

Navigate to the Database section and select Migrations. This displays a list of all applied migrations, including their version numbers and descriptions. You can also see the status of each migration, indicating whether it was successful or failed. If a migration fails, you should review the migration scripts for errors and redeploy the application when they are fixed.
