Skip to content

Instantly share code, notes, and snippets.

@pavelfomin
Last active December 14, 2023 21:18
Show Gist options
  • Save pavelfomin/b41b45e9c275169521b307510087b39d to your computer and use it in GitHub Desktop.
Save pavelfomin/b41b45e9c275169521b307510087b39d to your computer and use it in GitHub Desktop.

Baseline flyway migrations

https://documentation.red-gate.com/fd/baseline-184127456.html

spring:
  flyway:
    baselineVersion: 3.6
    baselineOnMigrate: true

Tested the following scenarios:

  • empty db schema - schema is created, all of the migrations applied
o.f.core.internal.database.base.Schema   : Creating schema "foobar" ...
o.f.c.i.s.JdbcTableSchemaHistory         : Creating Schema History table "foobar"."flyway_schema_history" ...
o.f.core.internal.command.DbMigrate      : Current version of schema "foobar": null
o.f.core.internal.command.DbMigrate      : Migrating schema "foobar" to version "1.0 - description for 1.0 version"
o.f.c.i.s.DefaultSqlScriptExecutor       : DB: schema "foobar" already exists, skipping (SQL State: 42P06 - Error Code: 0)
o.f.core.internal.command.DbMigrate      : Migrating schema "foobar" to version "1.1 - description for 1.1 version"
o.f.core.internal.command.DbMigrate      : Migrating schema "foobar" to version "1.2 - description for 1.2 version"
o.f.core.internal.command.DbMigrate      : Migrating schema "foobar" to version "1.3 - description for 1.3 version"
o.f.core.internal.command.DbMigrate      : Migrating schema "foobar" to version "1.4 - description for 1.4 version"
o.f.core.internal.command.DbMigrate      : Migrating schema "foobar" to version "1.5 - description for 1.5 version"
o.f.core.internal.command.DbMigrate      : Migrating schema "foobar" to version "1.6 - description for 1.6 version"
o.f.core.internal.command.DbMigrate      : Migrating schema "foobar" to version "1.7 - description for 1.7 version"
o.f.core.internal.command.DbMigrate      : Migrating schema "foobar" to version "1.8 - description for 1.8 version"
o.f.core.internal.command.DbMigrate      : Migrating schema "foobar" to version "1.9 - description for 1.9 version"
o.f.core.internal.command.DbMigrate      : Migrating schema "foobar" to version "1.10 - description for 1.10 version"
o.f.core.internal.command.DbMigrate      : Migrating schema "foobar" to version "2.0 - description for 2.0 version"
o.f.core.internal.command.DbMigrate      : Migrating schema "foobar" to version "2.1 - description for 2.1 version"
o.f.core.internal.command.DbMigrate      : Migrating schema "foobar" to version "2.2 - description for 2.2 version"
o.f.core.internal.command.DbMigrate      : Migrating schema "foobar" to version "3.0 - description for 3.0 version"
o.f.core.internal.command.DbMigrate      : Migrating schema "foobar" to version "3.1 - description for 3.1 version"
o.f.core.internal.command.DbMigrate      : Migrating schema "foobar" to version "3.2 - description for 3.2 version"
o.f.core.internal.command.DbMigrate      : Migrating schema "foobar" to version "3.3 - description for 3.3 version"
o.f.core.internal.command.DbMigrate      : Migrating schema "foobar" to version "3.4 - description for 3.4 version"
o.f.core.internal.command.DbMigrate      : Migrating schema "foobar" to version "3.5 - description for 3.5 version"
o.f.core.internal.command.DbMigrate      : Migrating schema "foobar" to version "3.6 - description for 3.6 version"
o.f.core.internal.command.DbMigrate      : Successfully applied 21 migrations to schema "foobar", now at version v3.6 (execution time 00:00.082s)
  • fully populated schema with all of the migrations previously applied
    • including flyway migration table - no migrations necessary
    o.f.core.internal.command.DbValidate     : Successfully validated 22 migrations (execution time 00:00.056s)
    o.f.core.internal.command.DbMigrate      : Current version of schema "foobar": 3.6
    o.f.core.internal.command.DbMigrate      : Schema "foobar" is up to date. No migration necessary.
    
    • w/out flyway migration table - migration table is created with a baseline version inserted
    o.f.c.i.s.JdbcTableSchemaHistory         : Schema history table "foobar"."flyway_schema_history" does not exist yet
    o.f.core.internal.command.DbValidate     : Successfully validated 21 migrations (execution time 00:00.067s)
    o.f.c.i.s.JdbcTableSchemaHistory         : Creating Schema History table "foobar"."flyway_schema_history" with baseline ...
    o.f.core.internal.command.DbBaseline     : Successfully baselined schema with version: 3.6
    o.f.core.internal.command.DbMigrate      : Current version of schema "foobar": 3.6
    o.f.core.internal.command.DbMigrate      : Schema "foobar" is up to date. No migration necessary.
    
    image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment