Skip to content

Support for application-module-specific database migrations #1067

Open
@odrotbohm

Description

@odrotbohm

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions