Flyway Lock Table Created in Public Schema Instead of Custom Schema
When using Flyway SDK 10.16 with YugabyteDB, the migration table is correctly created in the specified schema. However, the yb_flyway_lock_table is still created in the default public schema, even though defaultSchema and schemas are explicitly set to in the Flyway configuration.
Root Cause: Flyway internally creates the lock table (yb_flyway_lock_table) in the default PostgreSQL schema (public). The defaultSchema() setting in Flyway.configure() applies to the migration table but not to the lock table. For PostgreSQL-compatible databases like YugabyteDB, Flyway defaults to creating the lock table in public unless the connection-level search_path is modified.
Proposed Fix: Modify the FlywaySchemaHistory and lock table creation logic to respect the defaultSchema setting when creating the lock table. Ensure the lock table is created in the same schema as the migration table, defined by defaultSchema.
Acceptance Criteria: ✅ yb_flyway_lock_table should be created in the schema specified by defaultSchema. ✅ Migration table and lock table should be created in the same schema. ✅ No regression for existing PostgreSQL and YugabyteDB setups.
Test with Flyway version 10.16.1 and YugabyteDB version 2.19+. Ensure compatibility with PostgreSQL versions 13+. Confirm fix does not break backward compatibility with existing Flyway configurations.
Source: flyway/flyway