# Cassandra Migrator Job

To make data analysis more efficient, we are creating a new table called "***report\_user\_enrolments***" in the core cluster. In this table, the partitioning key will be "batchid" instead of "user\_id" as in the current "***sunbird\_courses.user\_enrolments***" table. Both tables have the same columns and datatypes. To migrate the data from the "***user\_enrolments***" table to the "***report\_user\_enrolments***" table, a Cassandra migration job will be used. The Cassandra migrator job performs the data migration from one Cassandra table to another. It reads data from a source table specified in the configuration, performs optional repartitioning based on provided columns, and writes the data to a target table using the Cassandra connector. After the migration is completed successfully, the code generates a metric event with information about the migration, such as the total number of records migrated and the time taken. This metric event is dispatched to a Kafka topic if the configuration allows it. In case of an exception or failure during the migration process, appropriate error handling is performed. The error is logged, and a metric event indicating the failure is generated and dispatched to the Kafka topic if configured.

**Data provider:**

**Cassandra**

1. user\_enrolments

<div data-full-width="true"><figure><img src="https://308610995-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4ZKyfmmhMWpPkD6iYvKF%2Fuploads%2FJA7gP8yYvrgJAjVLtUf5%2Fcassandra_migrator_job.png?alt=media&#x26;token=44df97f9-f1c2-4550-9822-b8cfafe0f3f1" alt=""><figcaption></figcaption></figure></div>

\ <br>
