Working setup plus one small application per way of getting it wrong (no @Primary, @Primary only, url vs jdbc-url, wrong repository package, Flyway auto-configuration), plain vs named @Transactional, and ChainedTransactionManager with a failing commit. Transcripts are written by the tests. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Uu7q8vPeREyT4218EJPzz1
26 lines
1.4 KiB
Plaintext
26 lines
1.4 KiB
Plaintext
# Spring Boot's Flyway auto-configuration when there are two databases
|
|
|
|
|
|
--- A. nothing configured: Flyway targets the @Primary DataSource and scans classpath:db/migration ---
|
|
startup failed: BeanCreationException -> BeanCreationException -> FlywayException
|
|
root cause: org.flywaydb.core.api.FlywayException: Found more than one migration with version 1
|
|
Offenders:
|
|
-> <multi-datasource>/target/classes/db/migration/customers/V1__customer.sql (SQL)
|
|
-> <multi-datasource>/target/classes/db/migration/orders/V1__purchase_order.sql (SQL)
|
|
|
|
--- B. spring.flyway.locations=classpath:db/migration/customers ---
|
|
startup failed: BeanCreationException -> PersistenceException -> SchemaManagementException
|
|
root cause: org.hibernate.tool.schema.spi.SchemaManagementException: Schema validation: missing table [purchase_order]
|
|
|
|
application started (Hibernate validation switched off so the databases can be inspected)
|
|
customers database tables: [CUSTOMER, flyway_schema_history]
|
|
orders database tables: []
|
|
|
|
--- C. as B, plus one hand-made Flyway bean for the orders database ---
|
|
startup failed: BeanCreationException -> PersistenceException -> SchemaManagementException
|
|
root cause: org.hibernate.tool.schema.spi.SchemaManagementException: Schema validation: missing table [customer]
|
|
|
|
application started (Hibernate validation switched off so the databases can be inspected)
|
|
customers database tables: []
|
|
orders database tables: [PURCHASE_ORDER, flyway_schema_history]
|