Skip to content

Comments

feat(EM-29): Define Per-Service Database Schema Migration Strategy with Flyway#51

Open
devin-ai-integration[bot] wants to merge 2 commits intofeat/microservices-migration-v2from
devin/1771606821-em29-database-migration-strategy
Open

feat(EM-29): Define Per-Service Database Schema Migration Strategy with Flyway#51
devin-ai-integration[bot] wants to merge 2 commits intofeat/microservices-migration-v2from
devin/1771606821-em29-database-migration-strategy

Conversation

@devin-ai-integration
Copy link

@devin-ai-integration devin-ai-integration bot commented Feb 20, 2026

feat(EM-29): Define Per-Service Database Schema Migration Strategy with Flyway

Summary

Adds libs/ftgo-database-migration/ shared library providing Flyway auto-configuration for per-service databases, initial V1 migration scripts for all four services, Flyway dependency additions to the version catalog, and migration strategy documentation.

Key changes:

  • Version catalog: Added flyway-postgresql library and flyway-mysql-all/flyway-postgresql-all bundles
  • libs/ftgo-database-migration/: New module with FtgoFlywayAutoConfiguration, custom FlywayMigrationProperties (ftgo.flyway.*), DatabaseNamingConvention utility, and a FlywayConfigurationCustomizer bean using Spring Boot's built-in interface
  • Migration scripts: V1 schemas for order-service (orders, order_line_items), consumer-service (consumers), courier-service (courier, courier_actions), restaurant-service (restaurants, restaurant_menu_items)
  • Documentation: docs/database/migration-strategy.md covering naming conventions, Flyway config, schema details, and best practices

Updates since last revision

  • Replaced the custom FlywayConfigurationCustomizer functional interface with Spring Boot's built-in org.springframework.boot.autoconfigure.flyway.FlywayConfigurationCustomizer. The ftgo.flyway.* properties now correctly propagate to Flyway's FluentConfiguration via Spring Boot's lifecycle.
  • Removed the redundant FlywayMigrationStrategy bean (the @ConditionalOnProperty on FtgoFlywayAutoConfiguration already gates on ftgo.flyway.enabled).
  • Cleaned up unused imports.

Review & Testing Checklist for Human

  • SQL schemas vs. JPA entity alignment. The migration DDL was hand-derived from domain entities. Verify column names/types match what Hibernate expects under ddl-auto: validate. In particular: the courier table is singular (no @Table annotation on Courier.java — Hibernate's default naming strategy may produce a different name), and PaymentInformation is not annotated with @Embeddable which may cause mapping issues at startup.
  • Database name mismatch with existing service configs. DatabaseNamingConvention defines constants like ftgo_order_service_db, but existing application.yml files point to ftgo_order_service (no _db suffix). Confirm which convention is intended and reconcile.
  • Module is not included in any settings.gradle. The constraint says not to modify root settings.gradle, so this module exists on disk but isn't part of the Gradle build. CI does not compile or run the unit tests for this module. Confirm this is acceptable for now or if a separate composite build inclusion is needed.

Recommended test plan:

  1. Temporarily include libs/ftgo-database-migration in a settings file and add it as a dependency to one service (e.g., order-service).
  2. Start a local MySQL instance and create the database (e.g., ftgo_order_service_db).
  3. Start the service and verify:
    • Flyway runs on startup
    • flyway_schema_history table is created
    • V1 migration is applied successfully
    • Service starts without Hibernate validation errors
  4. Inspect the generated schema to confirm it matches the JPA entity mappings.

Notes

  • Link to Devin run: https://app.devin.ai/sessions/a82da19a677d4f97a0f6a4283f03784f
  • Requested by: @abj453demo
  • All 11 CI checks passed (build, security/license scans).
  • The application-flyway-defaults.yml file contains both spring.flyway.* and ftgo.flyway.* sections. The spring.flyway.* section is redundant since the FlywayConfigurationCustomizer bean overrides those values. The profile is also never activated by default, so this file has no effect unless explicitly included.

…th Flyway

- Create libs/ftgo-database-migration/ shared library with Flyway auto-configuration
- Add FtgoFlywayAutoConfiguration with Spring Boot auto-config registration
- Add FlywayMigrationProperties for configurable migration behavior
- Add DatabaseNamingConvention utility for per-service database naming
- Create initial V1 migration scripts for all services:
  - order-service: orders, order_line_items tables
  - consumer-service: consumers table
  - courier-service: courier, courier_actions tables
  - restaurant-service: restaurants, restaurant_menu_items tables
- Add flyway-postgresql dependency and flyway bundles to version catalog
- Add database migration strategy documentation in docs/database/
- Add unit tests for naming conventions and properties

Co-Authored-By: Alex Baker <alexandercommander453@gmail.com>
@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

…nused custom interface and imports

Co-Authored-By: Alex Baker <alexandercommander453@gmail.com>
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.

0 participants