...
If any adopter wanted to build and deploy any one of the services, then the adopter needed to create all the cassandra Cassandra keyspaces by executing the existing cassandra-migration module, even though the adopter was only adopting a specific service. There is no way for an adopter to only create/migrate specific keyspaces. Furthermore, determining which release a specific migration script is introduced in is difficult.
Key Design Problems
Separate Group the migration script based on respective services/repos/keyspaces.
Remove the bundling on script as a part of cassandra-migration module and variabilise the script path.
Variabilize the keyspace for cassandra-migration module.
Maintain the release version that in which release version that script introducedVariabilize the script location for cassandra-migration module.
Design
Each keyspace will have its own cassandra_migration_version and cassandra_migration_version_counts table.
Add the release version in the filename.
...
.
...
Sample of cassandra_migration_version and cassandra_migration_version_counts table:
...
Separate all the migration script based on repos and keyspaces:
Option 1: push it to
the respective repo
Option 2: Keep in sunbird-utils repo and group is based on keyspace.
Mapping of the available keyspaces with repos
Repo Name | Keyspaces |
---|---|
sunbird-lms-service | sunbird |
groups-service | sunbird_groups |
sunbird-notification-service | sunbird_notifications |
sunbird-course-service | sunbird_courses |
...
Command 1:
Code Block |
---|
java -jar \
-Dcassandra.migration.scripts.locations=filesystem:<absolute or relative path>/db/migration/cassandra \
-Dcassandra.migration.cluster.contactpoints=localhost \
-Dcassandra.migration.cluster.port=9042 \
-Dcassandra.migration.cluster.username=username \
-Dcassandra.migration.cluster.password=password \
-Dcassandra.migration.keyspace.name=keyspace_name \
target/*-jar-with-dependencies.jar migrate |
Command 2:
Code Block |
---|
java -cp "cassandra-migration-0.0.1-SNAPSHOT-jar-with-dependencies.jar" com.contrastsecurity.cassandra.migration.utils.MigrationScriptEntryPoint |
The system environment listed below is required for command 2.
System Env
Code Block |
---|
sunbird_cassandra_keyspace=<keyspace_name> sunbird_cassandra_migration_location="filesystem:<absolute or relative path>/db/migration/cassandra" |