Skip to content

Conversation

@duanemay
Copy link
Member

@duanemay duanemay commented Dec 10, 2025

Remove explicit pinning of Flyway and MariaDB drivers, which makes us in sync with the Spring Boot BOM values.
Upgrade Flyway from 7.15.0 to 11.7.2 and MariaDB drivers from 2.7.12 to 3.5.6

  • Add permitMysqlScheme to JDBC URL for mariadb driver
    To connect to jdbc:mysql: must add &permitMysqlScheme=true
    otherwise change to jdbc:mariadb:

  • Enable Flyway cleanDisabled configuration during tests

  • Handle Flyway change in transaction use

    • Newer Flyway versions run migrations in a transaction.
    • CONCURRENTLY cannot be used inside a transaction, which causes hangs
    • Create index without CONCURRENTLY to allow execution within a transaction
    • The IF NOT EXISTS clause prevents errors if the index already exists

    • If the migration already ran successfully (with CONCURRENTLY):
    • The index exists
    • Flyway won't re-run it (already in schema_version)
    • repair() updates the checksum if needed
    • No errors occur

    • If the migration hung/failed:
    • It's not marked as successful in schema_version
    • The fixed version will run
    • IF NOT EXISTS prevents errors if the index was partially created

  • Handle exception for mariadb

  • Use the lower_case_table_names flag on MySQL

  • Ignore columnNamesAreLowercase on MySQL

    • Since column names are not case-sensitive in MySQL on any platform and are returned in mixed case.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR upgrades the Flyway database migration framework by removing explicit version pinning for Flyway and MariaDB JDBC driver dependencies, allowing them to be managed by Spring Boot's dependency management. The upgrade also migrates to Flyway's modular architecture with database-specific driver modules.

  • Removes explicit version overrides for Flyway (7.15.0), MariaDB driver (2.7.12), and HSQLDB (2.7.4), allowing Spring Boot BOM to manage versions
  • Migrates from single flyway-core dependency to database-specific modules (flyway-database-hsqldb, flyway-mysql, flyway-database-postgresql)
  • Adds permitMysqlScheme=true configuration to allow MariaDB driver to connect to MySQL scheme URLs, supporting the migration to newer MariaDB driver versions

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
dependencies.gradle Removes version overrides for Flyway, MariaDB, and HSQLDB; adds Flyway database-specific module definitions
server/build.gradle Replaces flyway-core with database-specific Flyway modules; moves MariaDB driver from implementation to testImplementation
uaa/build.gradle Adds MariaDB JDBC driver as runtime dependency for production use
server/src/main/java/org/cloudfoundry/identity/uaa/db/beans/FlywayConfiguration.java Adds configurable Flyway clean-disabled setting with default value for production safety
server/src/main/java/org/cloudfoundry/identity/uaa/db/beans/DatabaseConfiguration.java Adds MySQL scheme URL customizer for MariaDB driver compatibility; updates comments for clarity
server/src/test/java/org/cloudfoundry/identity/uaa/db/beans/DatabasePropertiesTest.java Adds tests to verify database URL configuration including new permitMysqlScheme parameter
server/src/test/java/org/cloudfoundry/identity/uaa/db/TableAndColumnNormalizationTest.java Updates database metadata queries to specify catalog and improves table validation logic; adds permitMysqlScheme to test URL
server/src/test/java/org/cloudfoundry/identity/uaa/db/DbMigrationIntegrationTestParent.java Enables Flyway clean operation for tests by setting spring.flyway.clean-disabled=false

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@duanemay duanemay marked this pull request as draft December 11, 2025 20:32
…to 3.5.6

These and hsqldb are now in sync with spring-boot bom.
To connect to jdbc:mysql: must add &permitMysqlScheme=true
otherwise change to jdbc:mariadb:
- Newer Flyway versions run migrations in a transaction.
- CONCURRENTLY cannot be used inside a transaction, which causes hangs
- Create index without CONCURRENTLY to allow execution within a transaction
- The IF NOT EXISTS clause prevents errors if the index already exists

• If the migration already ran successfully (with CONCURRENTLY):
  • The index exists
  • Flyway won't re-run it (already in schema_version)
  • repair() updates the checksum if needed
  • No errors occur

• If the migration hung/failed:
  • It's not marked as successful in schema_version
  • The fixed version will run
  • IF NOT EXISTS prevents errors if the index was partially created
@duanemay
Copy link
Member Author

With the change in how flyway runs migrations in separate transactions, CONCURRENTLY was not allowed in some migrations. See 6b3c8f0 for more info.

Verified that a database with the updated migrations that were already applied do not cause a problem since, we do a "baseFlyway.repair();" before the "baseFlyway.migrate();" The checksum fields will be updated on the changed migrations.

Database: jdbc:postgresql:uaa?connectTimeout=10 (PostgreSQL 17.7)
Repair of failed migration in Schema History table "public"."schema_version" not necessary. No failed migration detected.
Repairing Schema History table for version 4.99.1575367461 (Description: revocable token index, Type: SQL, Checksum: 86497166)  ...
Repairing Schema History table for version 4.101.1631562784 (Description: Add LowerIndex To Users, Type: SQL, Checksum: -903415912)  ...
Repairing Schema History table for version 4.101.1639764160 (Description: Add LowerIndex To Users Wo Origin, Type: SQL, Checksum: -808361628)  ...
Repairing Schema History table for version 4.109 (Description: IdP AliasZid IdzId Index, Type: SQL, Checksum: 1033466880)  ...
Repairing Schema History table for version 4.111 (Description: IdP active and type in zone Index, Type: SQL, Checksum: -339255243)  ...
Repairing Schema History table for version 4.113 (Description: Add group membership idz origin idx, Type: SQL, Checksum: -943252280)  ...
Successfully repaired schema history table "public"."schema_version" (execution time 00:00.096s).
Current version of schema "public": 4.113
Schema "public" is up to date. No migration necessary.

@duanemay duanemay marked this pull request as ready for review December 16, 2025 20:12
@duanemay duanemay requested a review from Copilot December 16, 2025 20:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant