spring-projects / spring-projects/spring-boot

Support Cassandra with Flyway

Open
#47,863 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement
Dominant language
Java
Stars
81.5k
Forks
42.7k
Avg merge
2d 4h
Merged PRs (30d)
65

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with FlywayAutoConfiguration and reproduce the failure using the linked cassandra-flyway minimal repository, comparing the test with and without spring-jdbc. Determine whether Cassandra migrations can run without spring-jdbc and verify the expected startup migration behavior with the repository's test.

Written by the indexing model from the issue text.

Assessment

Tech stack
cassandra, java, spring-boot
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.