Skip to content

Support Cassandra with Flyway #47863

@rbleuse

Description

@rbleuse

Flyway added support to Cassandra by using the jdbc driver cassandra-jdbc-wrapper
cf https://documentation.red-gate.com/fd/cassandra-database-277579306.html

Reading the official spring documentation, it seems by just adding the flyway dependency for Cassandra and setting the correct flyway url is enough to execute migrations on startup, however this is not the case

cf https://docs.spring.io/spring-boot/how-to/data-initialization.html#howto.data-initialization.migration-tool.flyway

To automatically run Flyway database migrations on startup, add the appropriate Flyway module to your classpath. In-memory and file-based databases are supported by org.flywaydb:flyway-core. Otherwise, a database-specific module is required. For example, use org.flywaydb:flyway-database-postgresql with PostgreSQL and org.flywaydb:flyway-mysql with MySQL.

Alternatively, you can use Flyway’s native DataSource by setting spring.flyway.[url,user,password] in external properties. Setting either spring.flyway.url or spring.flyway.user is sufficient to cause Flyway to use its own DataSource.

After digging further, FlywayAutoConfiguration is configured only when JdbcUtils class is in the classpath, which is in spring-jdbc

Do we really need spring-jdbc if we just want to execute migration scripts ?

Here is a minimal repo : https://github.com/rbleuse/cassandra-flyway

Running test as-is, we're getting table users does not exist error.
After uncommenting spring-jdbc dependency from gradle dependencies, the test passes because Flyway successfully executed migrations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions