Skip to content

Add DependsOnDatabaseInitializationDetector so engines wait for database initializers#4222

Open
nikhiln64 wants to merge 2 commits into
flowable:mainfrom
nikhiln64:feat/depends-on-database-initialization-detector
Open

Add DependsOnDatabaseInitializationDetector so engines wait for database initializers#4222
nikhiln64 wants to merge 2 commits into
flowable:mainfrom
nikhiln64:feat/depends-on-database-initialization-detector

Conversation

@nikhiln64

@nikhiln64 nikhiln64 commented Jul 15, 2026

Copy link
Copy Markdown

Implements #4213, following the approach @filiphr outlined there ("You can go ahead and create a PR for this").

What: a FlowableDependsOnDatabaseInitializationDetector extending Spring Boot's AbstractBeansOfTypeDependsOnDatabaseInitializationDetector for org.flowable.common.engine.api.Engine (covering process/cmmn/dmn/app/idm engines through the shared interface, no bean names), registered under the DependsOnDatabaseInitializationDetector SPI in spring.factories. Spring Boot's DatabaseInitializationDependencyConfigurer then orders every engine bean after Flyway/Liquibase/spring.sql.init initializers.

Opt-out: flowable.depends-on-database-initialization-detection=false (default true), mirroring the JPA detector's opt-out pattern per the issue discussion; documented in additional-spring-configuration-metadata.json.

Testing: FlowableDependsOnDatabaseInitializationDetectorTest uses ApplicationContextRunner with spring.sql.init and asserts the processEngine bean definition gains dependsOn on dataSourceScriptDatabaseInitializer, plus the opt-out case. Verified the assertion goes red when the spring.factories registration is removed. I can add a Flyway-based sample under flowable-spring-boot-samples as a follow-up if you'd prefer that shape of test as well.

  • Unit tests added
  • Documentation: property registered in configuration metadata

Developed with AI assistance (Claude Code), reviewed and driven by a human.


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

…ase initializers

Flowable engines create/validate their own schema on engine build, but
Spring Boot gave no ordering guarantee between engine beans and managed
database initializers (Flyway, Liquibase, spring.sql.init). Register a
FlowableDependsOnDatabaseInitializationDetector for all Engine beans via
the DependsOnDatabaseInitializationDetector SPI, with an opt-out
property (flowable.depends-on-database-initialization-detection),
following the approach outlined by @filiphr in flowable#4213.

@filiphr filiphr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @nikhiln64. This looks good, I've only left some comments for the tests

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