Skip to content

__root module Flyway migrations are not executed during a test #1750

@MartinAhrer

Description

@MartinAhrer

I'm using per module Flyway database migration scripts.

@ModuleSlicing(extraIncludes = ['integrationtest', 'catalog'])
@DataJpaTest
@AutoConfigureTestDatabase(replace = NONE)
@TestPropertySource(properties = """
    spring.jpa.show-sql=true
""")
class OrderRepositorySpec extends AbstractAggregateRootRepositorySpecification<Order, OrderIdentifier> {

    @Autowired
    OrderFactory entityFactory

    @Autowired
    OrderRepository repository
}

A db/migration/__root resource directory containes the script for adding the Spring modulith tables. However it is not executed when a test (database integration test) is executed.

Its the org.springframework.modulith.runtime.flyway.ActiveModules#shouldMigrate check that prevents that as its internal variable includedModules does not include the __root module.

However the __root migration is applied when the production code is run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions