...
Prefix:
V
for versioned andR
for repeatable migrationsVersion: Version with dots or underscores separate as many parts as you like (Not for repeatable migrations)
Separator:
__
(two underscores)Description: Underscores or spaces separate the words
Suffix:
.sql
Onboarding an existing database to use Flyway
Extract the DDL and reference data from production
First start by taking a snapshot of your most important database: production. This will be the starting point for migrations.
Generate a SQL script that includes the entire DDL (including indexes, triggers, procedures …) of the production database.
This script will form your baseline migration. Save it in the same location in the GIT repository where you plan to have your future versioned and repeatable migrations. Give it a relevant version number and description such as V0__baseline_migration.sql
.
Give these databases a baseline version
Now comes the time to baseline the databases that contain data (including production) with a baseline version. This will automatically happen when we run the flyway pipeline for the first time.. it will mark it as the baselined version on the flyway history schema that will be created and future migrations with version > 0.0 will be released as versioned migrations.