Flyway basics
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
run versioned migrations at startup.
Planned topics
- Add
flyway-core(and the PostgreSQL module if your Flyway version needs it: verify version before recording). - Place files in
src/main/resources/db/migrationnamedV1__baseline.sql,V2__add_sku.sql(two underscores). - At startup Flyway applies pending files and records them in
flyway_schema_historywith a checksum. - Changing an applied file changes its checksum, and startup fails.
- For an existing database use baseline (
baseline-on-migrate, with a baseline version) to mark what already exists.
Draft outline details
Demonstration
-- V1__baseline.sql
create table category (id bigint generated always as identity primary key, name text not null);
create table product (
id bigint generated always as identity primary key,
name text not null,
price numeric(12,2) not null,
category_id bigint references category(id));Check your understanding
Where does Flyway store what it has applied?
Show answer
In the flyway_schema_history table.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.