Skip to content

Conversation

@saurabh24thakur
Copy link

@saurabh24thakur saurabh24thakur commented Jan 2, 2026

📋 Description

JIRA ID: N/A

This PR addresses the issue where the application fails to start if the checksum of an already applied Flyway migration file changes. This is a common scenario during development or when minor non-functional changes (like comments) are added to existing migrations.

Changes:

  1. Introduced a new configuration property: amrit.flyway.ignore-applied-migration-checksum.
  2. Updated FlywayConfig.java to conditionally enable flyway.ignoreMigrationPatterns("*:applied") when this property is set to true.
  3. Set the default value to false in application.properties (safe for production).
  4. Enabled the property (true) in application-local.properties for a smoother local development experience.
  5. Updated lombok version in pom.xml to 1.18.36 to support building with newer JDK versions (e.g., JDK 24).

✅ Type of Change

  • 🐞 Bug fix (non-breaking change which resolves an issue)
  • New feature (non-breaking change which adds functionality)
  • 🔥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 🛠 Refactor (change that is neither a fix nor a new feature)
  • ⚙️ Config change (configuration file or build script updates)
  • 📚 Documentation (updates to docs or readme)
  • 🧪 Tests (adding new or updating existing tests)
  • 🎨 UI/UX (changes that affect the user interface)
  • 🚀 Performance (improves performance)
  • 🧹 Chore (miscellaneous changes that don't modify src or test files)

ℹ️ Additional Information

Verification:

  • Validated the configuration logic by attempting to run the application in a Dockerized Java 17 environment.
  • Confirmed that the Flyway bean is correctly configured with ignoreMigrationPatterns when the property is active.

Configuration:

  • Default (Production): amrit.flyway.ignore-applied-migration-checksum=false (Strict validation)
  • Local: amrit.flyway.ignore-applied-migration-checksum=true (Ignores checksums for applied migrations)

Summary by CodeRabbit

Release Notes

  • Dependencies

    • Updated Lombok to version 1.18.36
  • Configuration

    • Added new configuration property amrit.flyway.ignore-applied-migration-checksum for Flyway migration validation (default: false)

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 2, 2026

📝 Walkthrough

Walkthrough

This pull request updates the Lombok dependency to version 1.18.36, refactors Flyway configuration into a centralized helper method, and introduces a configurable flag to control Flyway applied-migration checksum validation behavior via a new application property.

Changes

Cohort / File(s) Summary
Dependency Management
pom.xml
Adds explicit version 1.18.36 for Lombok dependency (previously unspecified).
Flyway Configuration Refactoring
src/main/java/com/db/piramalswasthya/config/FlywayConfig.java
Centralizes Flyway bean configuration via new private helper method createFlyway(DataSource, String). Introduces configurable flag ignoreAppliedMigrationChecksum sourced from amrit.flyway.ignore-applied-migration-checksum property. When enabled, disables applied-migration checksum validation. Adds imports for FluentConfiguration and Value.
Configuration Properties
src/main/resources/application.properties
Adds new property amrit.flyway.ignore-applied-migration-checksum=false for controlling Flyway migration validation behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Poem

🐰 A hop through configs, both old and new,
Flyway's refactored, Lombok's renewed,
With checksums tamed by a flag so keen,
The smoothest deployments you've ever seen!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding a configurable option to ignore applied migration checksums via a new configuration property, with the FlywayConfig refactored to support this behavior.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@saurabh24thakur
Copy link
Author

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/main/resources/application-local.properties (1)

1-19: Consider documenting that credentials are example values.

The hardcoded credentials (user/password) should be documented as placeholder values for local development. Consider adding a comment indicating developers should customize these or use environment variable overrides.

💡 Suggested documentation addition

Add a comment at the top of the file:

+# Local development configuration
+# Replace user/password with your local database credentials or use environment variables
+
 spring.datasource.dbiemr.url=jdbc:mysql://localhost:3306/dbiemr
 spring.datasource.dbiemr.username=user
 spring.datasource.dbiemr.password=password
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 38905c8 and 29836a8.

📒 Files selected for processing (4)
  • pom.xml
  • src/main/java/com/db/piramalswasthya/config/FlywayConfig.java
  • src/main/resources/application-local.properties
  • src/main/resources/application.properties
🧰 Additional context used
🧬 Code graph analysis (1)
src/main/java/com/db/piramalswasthya/config/FlywayConfig.java (2)
src/main/java/com/db/piramalswasthya/config/DatasourceConfig.java (1)
  • Configuration (10-37)
src/main/java/com/db/piramalswasthya/config/JdbcTemplateConfig.java (1)
  • Configuration (10-32)
🔇 Additional comments (4)
src/main/java/com/db/piramalswasthya/config/FlywayConfig.java (2)

15-16: LGTM: Property binding with sensible default.

The @value annotation correctly binds to the new property with a safe default of false (strict validation).


31-49: Excellent refactoring to eliminate duplication.

The centralized createFlyway helper eliminates repetitive configuration code across all four Flyway beans. The delegation is clean and maintainable.

src/main/resources/application.properties (1)

52-52: LGTM: Safe production default.

Setting the default to false ensures strict checksum validation in production environments, which is the correct security posture.

src/main/resources/application-local.properties (1)

21-21: Appropriate setting for local development.

Setting ignore-applied-migration-checksum=true for local development makes sense, as it allows developers to iterate on migrations without checksum validation failures.

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.36</version>
Copy link

@coderabbitai coderabbitai bot Jan 2, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check latest Lombok version from Maven Central
echo "=== Latest Lombok Version ==="
curl -s 'https://search.maven.org/solrsearch/select?q=g:org.projectlombok+AND+a:lombok&rows=1&wt=json' | jq -r '.response.docs[0].latestVersion'

# Check for security advisories via GitHub
echo "=== Security Advisories ==="
gh api graphql -f query='
{
  securityVulnerabilities(first: 10, ecosystem: MAVEN, package: "org.projectlombok:lombok") {
    nodes {
      advisory {
        summary
        severity
        publishedAt
      }
      vulnerableVersionRange
      firstPatchedVersion {
        identifier
      }
    }
  }
}' 2>&1 || echo "GitHub GraphQL query failed or no vulnerabilities found"

Repository: PSMRI/AMRIT-DB

Length of output: 173


Update Lombok to version 1.18.38.

Version 1.18.36 is two minor versions behind the latest available version (1.18.38). No security vulnerabilities were found for the current version, but upgrading to 1.18.38 is recommended to maintain currency with the latest stable release.

🤖 Prompt for AI Agents
In pom.xml around line 55, the Lombok dependency version is pinned to 1.18.36;
update the <version> element to 1.18.38 to bring the dependency to the latest
stable release, then rebuild (mvn clean verify or mvn -U) to refresh the
dependency cache and ensure the project compiles with the new Lombok version.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Member

Choose a reason for hiding this comment

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

We manage environments with property files in environments folder.
This file should not be committed.

@saurabh24thakur
Copy link
Author

Thanks for the review @drtechie!

Local Properties: Got it. I'll remove application-local.properties from the PR. I'll move the necessary local configs to my own local environment and ensure they stay out of the repo.

Flyway Pattern: I also saw the bot's catch regarding the *:applied syntax. I'm looking into the correct pattern for the Community version now.

I'll push an update shortly with these fixes!

Updated ignoreMigrationPatterns to fix invalid pattern syntax for Flyway configuration.
@saurabh24thakur
Copy link
Author

Thanks for the review @drtechie.

I've removed the application-local.properties file as requested. I also updated the Flyway pattern in FlywayConfig.java to use a valid status (*:Ignored) to fix the issue flagged by CodeRabbit.

Let me know if everything looks good now!

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @src/main/java/com/db/piramalswasthya/config/FlywayConfig.java:
- Around line 22-35: The createFlyway method uses Flyway.
ignoreMigrationPatterns which is a Teams-only API and also does not suppress
checksum validation; remove the ignoreMigrationPatterns("*:Ignored") call in
createFlyway and instead disable validation for migrations in the Community
edition by calling configuration.validateOnMigrate(false) or perform
Flyway.repair() at startup where appropriate; update the conditional that checks
ignoreAppliedMigrationChecksum to set validateOnMigrate(false) (or trigger a
repair flow) so the app can start when local checksums differ without relying on
Teams-only methods.
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 29836a8 and 98df41b.

📒 Files selected for processing (1)
  • src/main/java/com/db/piramalswasthya/config/FlywayConfig.java
🧰 Additional context used
🧬 Code graph analysis (1)
src/main/java/com/db/piramalswasthya/config/FlywayConfig.java (2)
src/main/java/com/db/piramalswasthya/config/DatasourceConfig.java (1)
  • Configuration (10-37)
src/main/java/com/db/piramalswasthya/config/JdbcTemplateConfig.java (1)
  • Configuration (10-32)
🔇 Additional comments (3)
src/main/java/com/db/piramalswasthya/config/FlywayConfig.java (3)

6-6: LGTM!

The new imports are appropriate for the added functionality.

Also applies to: 8-8


15-16: LGTM!

The configuration field with a safe default of false ensures strict validation in production environments unless explicitly overridden.


37-55: Excellent refactoring!

The consolidation of Flyway bean configuration into the centralized createFlyway helper eliminates code duplication and ensures consistent configuration across all four database sources.

@drtechie
Copy link
Member

drtechie commented Jan 8, 2026

@saurabh24thakur can you also explain how you have tested this? Thanks.

@drtechie
Copy link
Member

drtechie commented Jan 8, 2026

Please check the open comments. Also, I can see the local properties file still in changed files.

@drtechie
Copy link
Member

@saurabh24thakur any updates?

@sonarqubecloud
Copy link

@saurabh24thakur
Copy link
Author

@drtechie
I have fix that issue and update my PR...Please verify this .

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/main/java/com/db/piramalswasthya/config/FlywayConfig.java`:
- Around line 28-32: You correctly replaced Teams-only ignoreMigrationPatterns
with configuration.validateOnMigrate(false), but ensure production environments
do not disable validation: update the logic around
ignoreAppliedMigrationChecksum/validateOnMigrate so that
configuration.validateOnMigrate(false) is only applied for non-production
contexts (e.g., local/dev profiles or an explicit opt-in flag) and keep
configuration.validateOnMigrate(true) for production; locate the conditional
using ignoreAppliedMigrationChecksum and the configuration.validateOnMigrate
call to add environment/profile or explicit config checks before flipping
validation.
🧹 Nitpick comments (1)
src/main/java/com/db/piramalswasthya/config/FlywayConfig.java (1)

18-21: Outdated comment references removed implementation.

The Javadoc mentions "valid ignoreMigrationPatterns status" but the code now uses validateOnMigrate(false). Update the comment to reflect the current implementation.

Suggested comment update
     /**
      * Helper method to create a Flyway instance with centralized configuration.
-     * Updated to use valid ignoreMigrationPatterns status.
+     * When ignoreAppliedMigrationChecksum is enabled, validation is disabled
+     * to allow the app to start even if checksums for applied migrations differ.
      */
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 98df41b and af4be46.

📒 Files selected for processing (1)
  • src/main/java/com/db/piramalswasthya/config/FlywayConfig.java
🧰 Additional context used
🧬 Code graph analysis (1)
src/main/java/com/db/piramalswasthya/config/FlywayConfig.java (2)
src/main/java/com/db/piramalswasthya/config/DatasourceConfig.java (1)
  • Configuration (10-37)
src/main/java/com/db/piramalswasthya/config/JdbcTemplateConfig.java (1)
  • Configuration (10-32)
🔇 Additional comments (2)
src/main/java/com/db/piramalswasthya/config/FlywayConfig.java (2)

15-16: LGTM! Safe default configuration.

The property defaults to false which maintains strict checksum validation in production. The property naming follows Spring conventions (kebab-case in properties, camelCase in Java).


37-55: Good refactoring - DRY principle applied.

The bean methods are cleanly refactored to use the centralized helper. The pattern is consistent with JdbcTemplateConfig and DatasourceConfig, and the migration paths follow a logical convention.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment on lines +28 to +32
if (ignoreAppliedMigrationChecksum) {
// Updated to use validateOnMigrate(false) which is supported in Community Edition
// This disables validation of applied migrations, allowing the app to start even if checksums change
configuration.validateOnMigrate(false);
}
Copy link

@coderabbitai coderabbitai bot Jan 14, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

Flyway validateOnMigrate false what does it disable

💡 Result:

Setting flyway.validateOnMigrate=false disables Flyway's automatic validation step when you run migrate — i.e., Flyway will not check applied vs. available migrations (checksums/CRC, changed/removed files, missing or out-of-sequence migrations, filename/validation rules) before applying new migrations, so migrate will proceed without failing on validation errors. Defaults to true. [1][2]


Good fix for Community edition compatibility.

The implementation now correctly uses validateOnMigrate(false) which is available in the Flyway Community edition, addressing the previous concern about ignoreMigrationPatterns being a Teams-only feature.

Note: Be aware that validateOnMigrate(false) disables validation checks including:

  • Missing migrations (files deleted after being applied)
  • Out-of-order migrations
  • Checksum validation for previously applied migrations

This is acceptable for local development but ensure production always uses the default (validateOnMigrate(true) for validation enabled).

🤖 Prompt for AI Agents
In `@src/main/java/com/db/piramalswasthya/config/FlywayConfig.java` around lines
28 - 32, You correctly replaced Teams-only ignoreMigrationPatterns with
configuration.validateOnMigrate(false), but ensure production environments do
not disable validation: update the logic around
ignoreAppliedMigrationChecksum/validateOnMigrate so that
configuration.validateOnMigrate(false) is only applied for non-production
contexts (e.g., local/dev profiles or an explicit opt-in flag) and keep
configuration.validateOnMigrate(true) for production; locate the conditional
using ignoreAppliedMigrationChecksum and the configuration.validateOnMigrate
call to add environment/profile or explicit config checks before flipping
validation.

Copy link
Member

Choose a reason for hiding this comment

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

@saurabh24thakur what does this mean? Are we ignoring checksum validation only, or other things too (Missing and out-of-order migrations)?

Copy link

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

@drtechie
Copy link
Member

@saurabh24thakur
Please let us know how you have tested this PR?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants