{"id":22152156,"url":"https://github.com/findinpath/cassandra-migration-spring-boot-demo","last_synced_at":"2026-04-18T17:32:39.336Z","repository":{"id":112790693,"uuid":"221679002","full_name":"findinpath/cassandra-migration-spring-boot-demo","owner":"findinpath","description":"Proof of concept on how to perform Cassandra database schema migrations on application startup.","archived":false,"fork":false,"pushed_at":"2019-11-14T11:14:08.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-04T14:58:58.883Z","etag":null,"topics":["cassandra","migration","spring-boot","testcontainers"],"latest_commit_sha":null,"homepage":"https://www.findinpath.com/cassandra-migration-spring-boot/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/findinpath.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-14T11:13:42.000Z","updated_at":"2019-11-14T14:29:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"b6632ddc-0e15-40d8-8f95-c1fcbbf223c1","html_url":"https://github.com/findinpath/cassandra-migration-spring-boot-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/findinpath/cassandra-migration-spring-boot-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/findinpath%2Fcassandra-migration-spring-boot-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/findinpath%2Fcassandra-migration-spring-boot-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/findinpath%2Fcassandra-migration-spring-boot-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/findinpath%2Fcassandra-migration-spring-boot-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/findinpath","download_url":"https://codeload.github.com/findinpath/cassandra-migration-spring-boot-demo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/findinpath%2Fcassandra-migration-spring-boot-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31977964,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T17:30:12.329Z","status":"ssl_error","status_checked_at":"2026-04-18T17:29:59.069Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cassandra","migration","spring-boot","testcontainers"],"created_at":"2024-12-02T00:47:30.118Z","updated_at":"2026-04-18T17:32:39.307Z","avatar_url":"https://github.com/findinpath.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Demo for Cassandra schema migrations on application startup \n===========================================================\n\nThis proof of concept application shows how to perform Cassandra database schema\nmigrations on application startup.\nIn the relational database world,  [flyway](https://flywaydb.org/)\nis extensively used for such purposes. On the other hand, there is no \nstandard tool at the moment for performing this job in the Cassandra world.\n\nThis often leads to runtime problems (e.g.: table not found) in the applications \nthat use Cassandra to store their data, because during the deployment the engineering team\nforgot to execute manually the schema migrations on the Cassandra database.\n\nThis demo makes use of the [cassandra-migration](https://github.com/patka/cassandra-migration)\nlibrary and integrates it into a [spring-boot](https://spring.io/projects/spring-boot) application\nso that on application startup the CQL migration files are applied one after the other on the database.\n\nWhat this demo is bringing new is the fact that it separates the concern of performing\nCassandra schema migrations (`CREATE`, `ALTER`, `DROP`) from the concern of performing \nCassandra queries related to the application functionality (`SELECT`, `INSERT`, `DELETE`). \nIn this way, there can be used a user with retricted role permissions for performing\nthe queries needed in covering the application functionality. \n\n\n## Setup Cassandra locally\n\nFor setting up the Cassandra database locally, there is no need to perform a manual installation\nof the database on your local machine.\n\n[Docker](https://www.docker.com/) can be used for creating a Cassandra container instance.\nBy default, the Cassandra image has no authentication or authorization. \n\nThis is fine for most of the usecases, but this demo makes a clear separation between the\nCassandra user needed for application purposes (mainly `SELECT`, `INSERT`, `DELETE` statements)\nand the Cassandra user needed for schema migration \npurposes (mainly `CREATE`, `ALTER`, `DROP` statements).\n\nHaving this clear separation of responsibilities makes the application less vulnerable.\nIn case that the application has a security hole, the attacker will be able to use only the\napplication user which is much more restricted in terms of permissions than the schema \nmigration user.\n\nDue to the fact, that there is no official Cassandra docker image that comes out of the\nbox with such roles, there will be needed a few manual steps in order to setup the database\nwhich is to be used by the demo application.\n\n*NOTE*: In case you intend only to run the tests from this project, this step is not necessary\nbecause the tests use the default Cassandra image (without authentication or authorization).\n\n```bash\n$ docker run  --name cassandra-migration-demo -v $(pwd)/cassandra:/demo -p 9042:9042 -d cassandra:latest -Dcassandra.config=/demo/cassandra.yaml\n```\n\nNow we can proceed to create the users and the keyspace for our demo by executing the following command:\n\n```bash\n$ docker exec -it cassandra-migration-demo cqlsh -u cassandra -p cassandra -f /demo/demo.cql\n```\n\n*NOTE* that the file `/demo/demo.cql` was already copied on the container while it got created. \n\nThere are now two users created :\n\n- `demo_user` WITH PASSWORD `notsoeasy`\n- `demo_migration` WITH PASSWORD `rollingstones`\n\nThis concludes the setup of the Cassandra database container on the localhost.\n\nWhen the Cassandra container required by this demo is not needed anymore, it can be removed:\n\n```bash\n$ docker rm cassandra-migration-demo\n``` \n\n\n## Running the DemoApplication\n\nWhen running the main class `com.findinpath.DemoApplication` the log output of the application\nshould resemble to the listing below:\n\n```bash\nINFO 2080 --- [           main] com.findinpath.DemoApplication           : Listing the schema migrations\nINFO 2080 --- [           main] com.findinpath.DemoApplication           : Schema migration applied: true version: 1 script name: 0001_create_users_table.cql\nINFO 2080 --- [           main] com.findinpath.DemoApplication           : Schema migration applied: true version: 2 script name: 0002_create_user_bookmarks_table.cql\n```\n\nAs seen in the listing, the applied migrations correspond to the .cql migration files\nfrom [migrations directory](./src/main/resources/cassandra/migration).\n\n\n## Running the tests\n\nIn order to run the tests, the [Cassandra module](https://www.testcontainers.org/modules/databases/cassandra/)\nfrom the [testcontainers](https://www.testcontainers.org) library is used for using a\nthrowaway docker container instance of Cassandra database.\n\nThe tests don't need any additional manual steps on the testing machine.\nAt the beginning of the tests a Cassandra docker container will be started, the CQL migrations\nwill be applied on top of it and then the tests will run. At the end of the tests, the Cassandra\ndatabase container will be deleted.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffindinpath%2Fcassandra-migration-spring-boot-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffindinpath%2Fcassandra-migration-spring-boot-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffindinpath%2Fcassandra-migration-spring-boot-demo/lists"}