Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for application-module-specific database migrations #1067

Open
odrotbohm opened this issue Feb 22, 2025 · 0 comments
Open

Support for application-module-specific database migrations #1067

odrotbohm opened this issue Feb 22, 2025 · 0 comments
Assignees
Labels
in: runtime General runtime support in: test support Spring Boot integration testing type: enhancement Major enhanvements, new features

Comments

@odrotbohm
Copy link
Member

Database migrations are usually run per application. In a modulith application, though, it makes sense to organize them by modules. Some migration tools allow organizing the files in folders but still ultimately order by the order naming scheme across all files found independent of the location:

- order
  - migration-1.sql
  - migration-3.sql
- customer
  - migration-2.sql

In integration tests for a particular module, this would already allow only executing the migrations for order for example. However, this would mean that the migrations might run in a different order in production, which might cause subtle problems. The reason for that is that, for example, Flyway calculates the overall order of execution across all files.

In a modulithic arrangement, however, the modular structure and dependency graph between the modules should guide the overall execution order. This can be mitigated by a versioning scheme that follows the dependency structure, but that again is error prone. We should provide Boot extensions that execute migrations in the order of the dependency graph:

  1. Determine module dependency graph.
  2. For each module, configure the migration to use the migrations from that module (code located in that module or scripts located in a module-specific folder).
  3. Execute migrations per module.

Related tickets

@odrotbohm odrotbohm added in: runtime General runtime support in: test support Spring Boot integration testing type: enhancement Major enhanvements, new features labels Feb 22, 2025
@odrotbohm odrotbohm self-assigned this Feb 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: runtime General runtime support in: test support Spring Boot integration testing type: enhancement Major enhanvements, new features
Projects
None yet
Development

No branches or pull requests

1 participant