From 6c076dfac1d938d18610364e5e7519b36f45dc56 Mon Sep 17 00:00:00 2001 From: Chethan Date: Thu, 8 Jan 2026 15:09:56 +0530 Subject: [PATCH] feat: Add YugabyteDB migration scripts for Sunbird Lern and Knowlg schemas, including CQL files and execution scripts. --- scripts/sunbird-yugabyte-migrations/README.md | 90 + .../sunbird-inquiry/execute_migrations.sh | 187 ++ .../sunbird-inquiry/hierarchy_store.cql | 12 + .../sunbird-inquiry/question_store.cql | 20 + .../sunbird-knowlg/category_store.cql | 21 + .../sunbird-knowlg/content_store.cql | 50 + .../sunbird-knowlg/contentstore.cql | 20 + .../sunbird-knowlg/dialcode_store.cql | 70 + .../sunbird-knowlg/dialcodes.cql | 52 + .../sunbird-knowlg/execute_migrations.sh | 196 ++ .../sunbird-knowlg/hierarchy_store.cql | 42 + .../sunbird-knowlg/lock_db.cql | 29 + .../sunbird-knowlg/platform_db.cql | 31 + .../sunbird-knowlg/script_store.cql | 21 + .../sunbird-knowlg/sunbird.cql | 104 + .../sunbird-lern/execute_migrations.sh | 167 ++ .../sunbird-lern/qmzbm_form_service.cql | 77 + .../sunbird-lern/sunbird.cql | 1832 +++++++++++++++++ .../sunbird-lern/sunbird_courses.cql | 374 ++++ .../sunbird-lern/sunbird_groups.cql | 128 ++ .../sunbird-lern/sunbird_notifications.cql | 148 ++ .../sunbird-lern/sunbird_programs.cql | 81 + 22 files changed, 3752 insertions(+) create mode 100644 scripts/sunbird-yugabyte-migrations/README.md create mode 100644 scripts/sunbird-yugabyte-migrations/sunbird-inquiry/execute_migrations.sh create mode 100644 scripts/sunbird-yugabyte-migrations/sunbird-inquiry/hierarchy_store.cql create mode 100644 scripts/sunbird-yugabyte-migrations/sunbird-inquiry/question_store.cql create mode 100644 scripts/sunbird-yugabyte-migrations/sunbird-knowlg/category_store.cql create mode 100644 scripts/sunbird-yugabyte-migrations/sunbird-knowlg/content_store.cql create mode 100644 scripts/sunbird-yugabyte-migrations/sunbird-knowlg/contentstore.cql create mode 100644 scripts/sunbird-yugabyte-migrations/sunbird-knowlg/dialcode_store.cql create mode 100644 scripts/sunbird-yugabyte-migrations/sunbird-knowlg/dialcodes.cql create mode 100644 scripts/sunbird-yugabyte-migrations/sunbird-knowlg/execute_migrations.sh create mode 100644 scripts/sunbird-yugabyte-migrations/sunbird-knowlg/hierarchy_store.cql create mode 100644 scripts/sunbird-yugabyte-migrations/sunbird-knowlg/lock_db.cql create mode 100644 scripts/sunbird-yugabyte-migrations/sunbird-knowlg/platform_db.cql create mode 100644 scripts/sunbird-yugabyte-migrations/sunbird-knowlg/script_store.cql create mode 100644 scripts/sunbird-yugabyte-migrations/sunbird-knowlg/sunbird.cql create mode 100644 scripts/sunbird-yugabyte-migrations/sunbird-lern/execute_migrations.sh create mode 100644 scripts/sunbird-yugabyte-migrations/sunbird-lern/qmzbm_form_service.cql create mode 100644 scripts/sunbird-yugabyte-migrations/sunbird-lern/sunbird.cql create mode 100644 scripts/sunbird-yugabyte-migrations/sunbird-lern/sunbird_courses.cql create mode 100644 scripts/sunbird-yugabyte-migrations/sunbird-lern/sunbird_groups.cql create mode 100644 scripts/sunbird-yugabyte-migrations/sunbird-lern/sunbird_notifications.cql create mode 100644 scripts/sunbird-yugabyte-migrations/sunbird-lern/sunbird_programs.cql diff --git a/scripts/sunbird-yugabyte-migrations/README.md b/scripts/sunbird-yugabyte-migrations/README.md new file mode 100644 index 000000000..2243c94d4 --- /dev/null +++ b/scripts/sunbird-yugabyte-migrations/README.md @@ -0,0 +1,90 @@ +# Sunbird YugabyteDB Migrations + +This repository contains CQL migration scripts for migrating Sunbird database schemas to YugabyteDB. + +## Structure + +``` +sunbird-lern/ # Learning and user management schemas +sunbird-knowlg/ # Knowledge and content management schemas +sunbird-inquiry/ # Assessment and inquiry schemas +``` + +## Usage + +### Running as Kubernetes Job + +In your Kubernetes job container, use the following script: + +```bash +#!/bin/bash + +# Set environment variables +export ENV=dev # or sb, prod +export YCQLSH_HOST=localhost +export YCQLSH_PORT=9042 +export YCQLSH_USERNAME=yugabyte +export YCQLSH_PASSWORD=yugabyte + +# Navigate to the migration directory +cd /path/to/sunbird-yugabyte-migrations + +# Run sunbird-lern migrations +cd sunbird-lern +./execute_migrations.sh + +# Run sunbird-knowlg migrations +cd ../sunbird-knowlg +./execute_migrations.sh $ENV + +# Run sunbird-inquiry migrations +cd ../sunbird-inquiry +./execute_migrations.sh $ENV +``` + +### Manual Execution + +**1. Copy files to YugabyteDB pod:** +```bash +kubectl cp sunbird-lern/ -n :/tmp/sunbird-lern/ +kubectl cp sunbird-knowlg/ -n :/tmp/sunbird-knowlg/ +kubectl cp sunbird-inquiry/ -n :/tmp/sunbird-inquiry/ +``` + +**2. Run migrations inside the pod:** +```bash +# sunbird-lern +cd /tmp/sunbird-lern +./execute_migrations.sh + +# sunbird-knowlg +cd /tmp/sunbird-knowlg +./execute_migrations.sh dev + +# sunbird-inquiry +cd /tmp/sunbird-inquiry +./execute_migrations.sh dev +``` + +## Environment Parameters + +- **sunbird-lern**: No environment parameter (uses fixed keyspace names) +- **sunbird-knowlg**: Requires environment (dev/sb/prod) - creates `{ENV}_category_store`, `{ENV}_content_store`, etc. +- **sunbird-inquiry**: Requires environment (dev/sb/prod) - creates `{ENV}_hierarchy_store`, `{ENV}_question_store` + +## Connection Configuration + +Override default connection settings using environment variables: +```bash +export YCQLSH_HOST=localhost +export YCQLSH_PORT=9042 +export YCQLSH_USERNAME=yugabyte +export YCQLSH_PASSWORD=yugabyte +``` + +## Output + +Each script generates: +- Colored console output showing progress +- Timestamped log file in the same directory +- Summary report of successful/failed migrations diff --git a/scripts/sunbird-yugabyte-migrations/sunbird-inquiry/execute_migrations.sh b/scripts/sunbird-yugabyte-migrations/sunbird-inquiry/execute_migrations.sh new file mode 100644 index 000000000..577e5e5b0 --- /dev/null +++ b/scripts/sunbird-yugabyte-migrations/sunbird-inquiry/execute_migrations.sh @@ -0,0 +1,187 @@ +#!/bin/bash + +##################################################### +# YugabyteDB CQL Migration Script +# Executes all CQL files in the sunbird-inquiry folder +##################################################### + +# Usage function +usage() { + echo "Usage: $0 [ENVIRONMENT]" + echo " ENVIRONMENT: Environment prefix for CQL files (e.g., dev, sb, prod)" + echo " Default: dev" + echo "" + echo "Examples:" + echo " $0 # Uses 'dev' as environment" + echo " $0 dev # Uses 'dev' as environment" + echo " $0 sb # Uses 'sb' as environment" + echo " $0 prod # Uses 'prod' as environment" + exit 1 +} + +# Get environment from parameter or use default +ENVIRONMENT="${1:-dev}" + +# Color codes for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Get the directory where the script is located +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Log file +LOG_FILE="${SCRIPT_DIR}/migration_$(date +%Y%m%d_%H%M%S).log" + +# YugabyteDB connection parameters (can be overridden by environment variables) +YCQLSH_HOST="${YCQLSH_HOST:-localhost}" +YCQLSH_PORT="${YCQLSH_PORT:-9042}" +YCQLSH_USERNAME="${YCQLSH_USERNAME:-yugabyte}" +YCQLSH_PASSWORD="${YCQLSH_PASSWORD:-yugabyte}" + +# Counter variables +TOTAL_FILES=0 +SUCCESSFUL_FILES=0 +FAILED_FILES=0 + +# Array to store failed files +declare -a FAILED_FILE_LIST + +##################################################### +# Function: Print colored message +##################################################### +print_message() { + local color=$1 + local message=$2 + echo -e "${color}${message}${NC}" + echo "[$(date '+%Y-%m-%d %H:%M:%S')] ${message}" >> "${LOG_FILE}" +} + +##################################################### +# Function: Print header +##################################################### +print_header() { + echo "" + print_message "${BLUE}" "==============================================" + print_message "${BLUE}" "$1" + print_message "${BLUE}" "==============================================" + echo "" +} + +##################################################### +# Function: Execute CQL file +##################################################### +execute_cql_file() { + local cql_file=$1 + local filename=$(basename "${cql_file}") + + print_message "${YELLOW}" "Processing: ${filename}" + + # Create temp file and replace ${ENV} with actual environment + local temp_file="${SCRIPT_DIR}/.tmp_${filename}" + sed "s/\${ENV}/${ENVIRONMENT}/g" "${cql_file}" > "${temp_file}" + + # Execute the CQL file using ycqlsh + set +e # Disable exit on error for this command + ycqlsh "${YCQLSH_HOST}" "${YCQLSH_PORT}" \ + -u "${YCQLSH_USERNAME}" \ + -p "${YCQLSH_PASSWORD}" \ + -f "${temp_file}" >> "${LOG_FILE}" 2>&1 + local exit_code=$? + set -e # Re-enable exit on error + + # Clean up temp file + rm -f "${temp_file}" + + if [ $exit_code -eq 0 ]; then + print_message "${GREEN}" "✓ SUCCESS: ${filename} executed successfully" + SUCCESSFUL_FILES=$((SUCCESSFUL_FILES + 1)) + else + print_message "${RED}" "✗ FAILED: ${filename} execution failed (exit code: $exit_code)" + FAILED_FILE_LIST+=("${filename}") + FAILED_FILES=$((FAILED_FILES + 1)) + fi + + echo "" +} + +##################################################### +# Main Script +##################################################### + +print_header "YugabyteDB CQL Migration Script - sunbird-inquiry" + +print_message "${BLUE}" "Configuration:" +echo " Environment: ${ENVIRONMENT}" +echo " Host: ${YCQLSH_HOST}" +echo " Port: ${YCQLSH_PORT}" +echo " Username: ${YCQLSH_USERNAME}" +echo " Script Directory: ${SCRIPT_DIR}" +echo " Log File: ${LOG_FILE}" +echo "" + +# Check if ycqlsh is available +if ! command -v ycqlsh &> /dev/null; then + print_message "${RED}" "ERROR: ycqlsh command not found. Please ensure YugabyteDB client is installed." + exit 1 +fi + +# Test connection to YugabyteDB +print_message "${YELLOW}" "Testing connection to YugabyteDB..." +if ycqlsh "${YCQLSH_HOST}" "${YCQLSH_PORT}" \ + -u "${YCQLSH_USERNAME}" \ + -p "${YCQLSH_PASSWORD}" \ + -e "DESCRIBE KEYSPACES;" >> "${LOG_FILE}" 2>&1; then + print_message "${GREEN}" "✓ Connection successful" + echo "" +else + print_message "${RED}" "✗ Connection failed. Please check your connection parameters." + exit 1 +fi + +# Define the order of execution for CQL files +CQL_FILES=( + "hierarchy_store.cql" + "question_store.cql" +) + +print_header "Starting CQL File Execution" + +# Execute each CQL file in order +for cql_file in "${CQL_FILES[@]}"; do + full_path="${SCRIPT_DIR}/${cql_file}" + + if [ -f "${full_path}" ]; then + TOTAL_FILES=$((TOTAL_FILES + 1)) + execute_cql_file "${full_path}" + else + print_message "${YELLOW}" "WARNING: ${cql_file} not found, skipping..." + echo "" + fi +done + +# Print summary +print_header "Migration Summary" + +echo "Total Files Processed: ${TOTAL_FILES}" +echo "Successful: ${SUCCESSFUL_FILES}" +echo "Failed: ${FAILED_FILES}" +echo "" + +if [ ${FAILED_FILES} -gt 0 ]; then + print_message "${RED}" "Failed Files:" + for failed_file in "${FAILED_FILE_LIST[@]}"; do + echo " - ${failed_file}" + done + echo "" + print_message "${RED}" "Migration completed with errors. Check log file: ${LOG_FILE}" + exit 1 +else + print_message "${GREEN}" "All migrations completed successfully!" + print_message "${BLUE}" "Log file: ${LOG_FILE}" +fi + +echo "" +print_message "${BLUE}" "==============================================" diff --git a/scripts/sunbird-yugabyte-migrations/sunbird-inquiry/hierarchy_store.cql b/scripts/sunbird-yugabyte-migrations/sunbird-inquiry/hierarchy_store.cql new file mode 100644 index 000000000..c05ecd352 --- /dev/null +++ b/scripts/sunbird-yugabyte-migrations/sunbird-inquiry/hierarchy_store.cql @@ -0,0 +1,12 @@ +CREATE KEYSPACE IF NOT EXISTS ${ENV}_hierarchy_store WITH replication = { + 'class': 'SimpleStrategy', + 'replication_factor': '1' +}; + +CREATE TABLE IF NOT EXISTS ${ENV}_hierarchy_store.questionset_hierarchy ( + identifier text, + hierarchy text, + instructions text, + outcomeDeclaration text, + PRIMARY KEY (identifier) +); \ No newline at end of file diff --git a/scripts/sunbird-yugabyte-migrations/sunbird-inquiry/question_store.cql b/scripts/sunbird-yugabyte-migrations/sunbird-inquiry/question_store.cql new file mode 100644 index 000000000..6c22b8588 --- /dev/null +++ b/scripts/sunbird-yugabyte-migrations/sunbird-inquiry/question_store.cql @@ -0,0 +1,20 @@ +CREATE KEYSPACE IF NOT EXISTS ${ENV}_question_store WITH replication = { + 'class': 'SimpleStrategy', + 'replication_factor': '1' +}; + +CREATE TABLE IF NOT EXISTS ${ENV}_question_store.question_data ( + identifier text, + body blob, + editorState text, + answer blob, + solutions text, + instructions text, + hints text, + media text, + responseDeclaration text, + interactions text, + outcomeDeclaration text, + feedback text, + PRIMARY KEY (identifier) +); \ No newline at end of file diff --git a/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/category_store.cql b/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/category_store.cql new file mode 100644 index 000000000..b9874f83c --- /dev/null +++ b/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/category_store.cql @@ -0,0 +1,21 @@ +CREATE KEYSPACE IF NOT EXISTS ${ENV}_category_store WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true; + +CREATE TABLE IF NOT EXISTS ${ENV}_category_store.category_definition_data ( + identifier text PRIMARY KEY, + forms map, + objectmetadata map +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; diff --git a/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/content_store.cql b/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/content_store.cql new file mode 100644 index 000000000..0720e2564 --- /dev/null +++ b/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/content_store.cql @@ -0,0 +1,50 @@ +CREATE KEYSPACE IF NOT EXISTS ${ENV}_content_store WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true; + + +CREATE TABLE IF NOT EXISTS ${ENV}_content_store.question_data ( + question_id text PRIMARY KEY, + body blob, + editorstate blob, + last_updated_on timestamp, + question blob, + solutions blob +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + + +CREATE TABLE IF NOT EXISTS ${ENV}_content_store.content_data ( + content_id text PRIMARY KEY, + body blob, + externallink text, + last_updated_on timestamp, + oldbody blob, + screenshots blob, + stageicons blob +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; diff --git a/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/contentstore.cql b/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/contentstore.cql new file mode 100644 index 000000000..f7ec189cd --- /dev/null +++ b/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/contentstore.cql @@ -0,0 +1,20 @@ +CREATE KEYSPACE IF NOT EXISTS content_store WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true; + +CREATE TABLE IF NOT EXISTS content_store.content_data ( + content_id text PRIMARY KEY, + body blob +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; \ No newline at end of file diff --git a/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/dialcode_store.cql b/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/dialcode_store.cql new file mode 100644 index 000000000..1ec8646f8 --- /dev/null +++ b/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/dialcode_store.cql @@ -0,0 +1,70 @@ +CREATE KEYSPACE IF NOT EXISTS ${ENV}_dialcode_store WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true; + + +CREATE TABLE IF NOT EXISTS ${ENV}_dialcode_store.publisher ( + identifier text PRIMARY KEY, + channel text, + created_on text, + name text, + updated_on text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + + +CREATE TABLE IF NOT EXISTS ${ENV}_dialcode_store.dial_code ( + identifier text PRIMARY KEY, + batchcode text, + channel text, + dialcode_index double, + generated_on text, + metadata text, + published_on text, + publisher text, + status text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS ${ENV}_dialcode_store.system_config ( + prop_key text PRIMARY KEY, + prop_value text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; diff --git a/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/dialcodes.cql b/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/dialcodes.cql new file mode 100644 index 000000000..ea448b39d --- /dev/null +++ b/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/dialcodes.cql @@ -0,0 +1,52 @@ +CREATE KEYSPACE IF NOT EXISTS dialcodes WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true; + +CREATE TABLE IF NOT EXISTS dialcodes.dialcode_images ( + filename text PRIMARY KEY, + channel text, + "config" map, + created_on timestamp, + dialcode text, + publisher text, + status int, + url text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + + +CREATE TABLE IF NOT EXISTS dialcodes.dialcode_batch ( + processid uuid PRIMARY KEY, + channel text, + "config" map, + created_on timestamp, + dialcodes list, + publisher text, + status int, + url text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; diff --git a/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/execute_migrations.sh b/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/execute_migrations.sh new file mode 100644 index 000000000..e492c905d --- /dev/null +++ b/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/execute_migrations.sh @@ -0,0 +1,196 @@ +#!/bin/bash + +##################################################### +# YugabyteDB CQL Migration Script +# Executes all CQL files in the sunbird-knowlg folder +##################################################### + +# Usage function +usage() { + echo "Usage: $0 [ENVIRONMENT]" + echo " ENVIRONMENT: Environment prefix for CQL files (e.g., dev, sb, prod)" + echo " Default: dev" + echo "" + echo "Examples:" + echo " $0 # Uses 'dev' as environment" + echo " $0 dev # Uses 'dev' as environment" + echo " $0 sb # Uses 'sb' as environment" + echo " $0 prod # Uses 'prod' as environment" + exit 1 +} + +# Get environment from parameter or use default +ENVIRONMENT="${1:-dev}" + +# Color codes for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Get the directory where the script is located +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Log file +LOG_FILE="${SCRIPT_DIR}/migration_$(date +%Y%m%d_%H%M%S).log" + +# YugabyteDB connection parameters (can be overridden by environment variables) +YCQLSH_HOST="${YCQLSH_HOST:-localhost}" +YCQLSH_PORT="${YCQLSH_PORT:-9042}" +YCQLSH_USERNAME="${YCQLSH_USERNAME:-yugabyte}" +YCQLSH_PASSWORD="${YCQLSH_PASSWORD:-yugabyte}" + +# Counter variables +TOTAL_FILES=0 +SUCCESSFUL_FILES=0 +FAILED_FILES=0 + +# Array to store failed files +declare -a FAILED_FILE_LIST + +##################################################### +# Function: Print colored message +##################################################### +print_message() { + local color=$1 + local message=$2 + echo -e "${color}${message}${NC}" + echo "[$(date '+%Y-%m-%d %H:%M:%S')] ${message}" >> "${LOG_FILE}" +} + +##################################################### +# Function: Print header +##################################################### +print_header() { + echo "" + print_message "${BLUE}" "==============================================" + print_message "${BLUE}" "$1" + print_message "${BLUE}" "==============================================" + echo "" +} + +##################################################### +# Function: Execute CQL file +##################################################### +execute_cql_file() { + local cql_file=$1 + local filename=$(basename "${cql_file}") + + print_message "${YELLOW}" "Processing: ${filename}" + + # Create temp file and replace ${ENV} with actual environment + local temp_file="${SCRIPT_DIR}/.tmp_${filename}" + sed "s/\${ENV}/${ENVIRONMENT}/g" "${cql_file}" > "${temp_file}" + + # Execute the CQL file using ycqlsh + set +e # Disable exit on error for this command + ycqlsh "${YCQLSH_HOST}" "${YCQLSH_PORT}" \ + -u "${YCQLSH_USERNAME}" \ + -p "${YCQLSH_PASSWORD}" \ + -f "${temp_file}" >> "${LOG_FILE}" 2>&1 + local exit_code=$? + set -e # Re-enable exit on error + + # Clean up temp file + rm -f "${temp_file}" + + if [ $exit_code -eq 0 ]; then + print_message "${GREEN}" "✓ SUCCESS: ${filename} executed successfully" + SUCCESSFUL_FILES=$((SUCCESSFUL_FILES + 1)) + else + print_message "${RED}" "✗ FAILED: ${filename} execution failed (exit code: $exit_code)" + FAILED_FILE_LIST+=("${filename}") + FAILED_FILES=$((FAILED_FILES + 1)) + fi + + echo "" +} + +##################################################### +# Main Script +##################################################### + +print_header "YugabyteDB CQL Migration Script - sunbird-knowlg" + +print_message "${BLUE}" "Configuration:" +echo " Environment: ${ENVIRONMENT}" +echo " Host: ${YCQLSH_HOST}" +echo " Port: ${YCQLSH_PORT}" +echo " Username: ${YCQLSH_USERNAME}" +echo " Script Directory: ${SCRIPT_DIR}" +echo " Log File: ${LOG_FILE}" +echo "" + +# Check if ycqlsh is available +if ! command -v ycqlsh &> /dev/null; then + print_message "${RED}" "ERROR: ycqlsh command not found. Please ensure YugabyteDB client is installed." + exit 1 +fi + +# Test connection to YugabyteDB +print_message "${YELLOW}" "Testing connection to YugabyteDB..." +if ycqlsh "${YCQLSH_HOST}" "${YCQLSH_PORT}" \ + -u "${YCQLSH_USERNAME}" \ + -p "${YCQLSH_PASSWORD}" \ + -e "DESCRIBE KEYSPACES;" >> "${LOG_FILE}" 2>&1; then + print_message "${GREEN}" "✓ Connection successful" + echo "" +else + print_message "${RED}" "✗ Connection failed. Please check your connection parameters." + exit 1 +fi + +# Define the order of execution for CQL files +# sunbird.cql should be executed first as it likely contains keyspace definitions +CQL_FILES=( + "sunbird.cql" + "lock_db.cql" + "dialcodes.cql" + "content_store.cql" + "contentstore.cql" + "category_store.cql" + "dialcode_store.cql" + "hierarchy_store.cql" + "platform_db.cql" + "script_store.cql" +) + +print_header "Starting CQL File Execution" + +# Execute each CQL file in order +for cql_file in "${CQL_FILES[@]}"; do + full_path="${SCRIPT_DIR}/${cql_file}" + + if [ -f "${full_path}" ]; then + TOTAL_FILES=$((TOTAL_FILES + 1)) + execute_cql_file "${full_path}" + else + print_message "${YELLOW}" "WARNING: ${cql_file} not found, skipping..." + echo "" + fi +done + +# Print summary +print_header "Migration Summary" + +echo "Total Files Processed: ${TOTAL_FILES}" +echo "Successful: ${SUCCESSFUL_FILES}" +echo "Failed: ${FAILED_FILES}" +echo "" + +if [ ${FAILED_FILES} -gt 0 ]; then + print_message "${RED}" "Failed Files:" + for failed_file in "${FAILED_FILE_LIST[@]}"; do + echo " - ${failed_file}" + done + echo "" + print_message "${RED}" "Migration completed with errors. Check log file: ${LOG_FILE}" + exit 1 +else + print_message "${GREEN}" "All migrations completed successfully!" + print_message "${BLUE}" "Log file: ${LOG_FILE}" +fi + +echo "" +print_message "${BLUE}" "==============================================" diff --git a/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/hierarchy_store.cql b/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/hierarchy_store.cql new file mode 100644 index 000000000..fff5978e1 --- /dev/null +++ b/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/hierarchy_store.cql @@ -0,0 +1,42 @@ +CREATE KEYSPACE IF NOT EXISTS ${ENV}_hierarchy_store WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true; + +CREATE TABLE IF NOT EXISTS ${ENV}_hierarchy_store.content_hierarchy ( + identifier text PRIMARY KEY, + hierarchy text, + relational_metadata text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + + +CREATE TABLE IF NOT EXISTS ${ENV}_hierarchy_store.framework_hierarchy ( + identifier text PRIMARY KEY, + hierarchy text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + diff --git a/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/lock_db.cql b/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/lock_db.cql new file mode 100644 index 000000000..563c775bd --- /dev/null +++ b/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/lock_db.cql @@ -0,0 +1,29 @@ +CREATE KEYSPACE IF NOT EXISTS lock_db WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true; + +CREATE TABLE IF NOT EXISTS lock_db.lock ( + "resourceId" text, + "resourceType" text, + "createdBy" text, + "createdOn" timestamp, + "creatorInfo" text, + "deviceId" text, + "expiresAt" timestamp, + "lockId" uuid, + "resourceInfo" text, + PRIMARY KEY ("resourceId", "resourceType") +) WITH CLUSTERING ORDER BY ("resourceType" ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE'; + \ No newline at end of file diff --git a/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/platform_db.cql b/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/platform_db.cql new file mode 100644 index 000000000..dfd2fc86c --- /dev/null +++ b/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/platform_db.cql @@ -0,0 +1,31 @@ +CREATE KEYSPACE IF NOT EXISTS ${ENV}_platform_db WITH replication = { + 'class': 'SimpleStrategy', + 'replication_factor': '1' +}; + +CREATE TABLE IF NOT EXISTS ${ENV}_platform_db.job_request ( + client_key text, + request_id text, + job_id text, + status text, + request_data text, + location text, + dt_file_created timestamp, + dt_first_event timestamp, + dt_last_event timestamp, + dt_expiration timestamp, + iteration int, + dt_job_submitted timestamp, + dt_job_processing timestamp, + dt_job_completed timestamp, + input_events int, + output_events int, + file_size bigint, + latency int, + execution_time bigint, + err_message text, + stage text, + stage_status text, + job_name text, + PRIMARY KEY (client_key, request_id) +); \ No newline at end of file diff --git a/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/script_store.cql b/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/script_store.cql new file mode 100644 index 000000000..7d91d7fdd --- /dev/null +++ b/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/script_store.cql @@ -0,0 +1,21 @@ +CREATE KEYSPACE IF NOT EXISTS ${ENV}_script_store WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true; + +CREATE TABLE IF NOT EXISTS ${ENV}_script_store.script_data ( + name text PRIMARY KEY, + reqmap text, + type text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; \ No newline at end of file diff --git a/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/sunbird.cql b/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/sunbird.cql new file mode 100644 index 000000000..75680272d --- /dev/null +++ b/scripts/sunbird-yugabyte-migrations/sunbird-knowlg/sunbird.cql @@ -0,0 +1,104 @@ +CREATE KEYSPACE IF NOT EXISTS sunbird WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true; + +CREATE TABLE IF NOT EXISTS sunbird.bulk_upload_process_task ( + processid text, + sequenceid int, + createdon timestamp, + data text, + failureresult text, + iterationid int, + lastupdatedon timestamp, + status int, + successresult text, + PRIMARY KEY (processid, sequenceid) +) WITH CLUSTERING ORDER BY (sequenceid ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + + +CREATE TABLE IF NOT EXISTS sunbird.assessment_item ( + id text PRIMARY KEY, + answers text, + assessmentitemid text, + assessmenttype text, + attempteddate text, + attemptid text, + contentid text, + courseid text, + createddate text, + evaluationstatus boolean, + maxscore text, + processingstatus boolean, + result text, + score text, + timetaken int, + userid text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_ai_contentid ON sunbird.assessment_item (contentid); +CREATE INDEX IF NOT EXISTS inx_ai_userid ON sunbird.assessment_item (userid); +CREATE INDEX IF NOT EXISTS inx_ai_assessmentitemid ON sunbird.assessment_item (assessmentitemid); +CREATE INDEX IF NOT EXISTS inx_ai_courseid ON sunbird.assessment_item (courseid); + + +CREATE TABLE IF NOT EXISTS sunbird.bulk_upload_process ( + id text PRIMARY KEY, + createdby text, + createdon timestamp, + data text, + failureresult text, + lastupdatedon timestamp, + objecttype text, + organisationid text, + processendtime text, + processstarttime text, + retrycount int, + status int, + storagedetails text, + successresult text, + taskcount int, + telemetrycontext map, + uploadedby text, + uploadeddate text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_status ON sunbird.bulk_upload_process (status); \ No newline at end of file diff --git a/scripts/sunbird-yugabyte-migrations/sunbird-lern/execute_migrations.sh b/scripts/sunbird-yugabyte-migrations/sunbird-lern/execute_migrations.sh new file mode 100644 index 000000000..82b27f5f8 --- /dev/null +++ b/scripts/sunbird-yugabyte-migrations/sunbird-lern/execute_migrations.sh @@ -0,0 +1,167 @@ +#!/bin/bash + +##################################################### +# YugabyteDB CQL Migration Script +# Executes all CQL files in the sunbird-lern folder +##################################################### + +# Color codes for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Get the directory where the script is located +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Log file +LOG_FILE="${SCRIPT_DIR}/migration_$(date +%Y%m%d_%H%M%S).log" + +# YugabyteDB connection parameters (can be overridden by environment variables) +YCQLSH_HOST="${YCQLSH_HOST:-localhost}" +YCQLSH_PORT="${YCQLSH_PORT:-9042}" +YCQLSH_USERNAME="${YCQLSH_USERNAME:-yugabyte}" +YCQLSH_PASSWORD="${YCQLSH_PASSWORD:-yugabyte}" + +# Counter variables +TOTAL_FILES=0 +SUCCESSFUL_FILES=0 +FAILED_FILES=0 + +# Array to store failed files +declare -a FAILED_FILE_LIST + +##################################################### +# Function: Print colored message +##################################################### +print_message() { + local color=$1 + local message=$2 + echo -e "${color}${message}${NC}" + echo "[$(date '+%Y-%m-%d %H:%M:%S')] ${message}" >> "${LOG_FILE}" +} + +##################################################### +# Function: Print header +##################################################### +print_header() { + echo "" + print_message "${BLUE}" "==============================================" + print_message "${BLUE}" "$1" + print_message "${BLUE}" "==============================================" + echo "" +} + +##################################################### +# Function: Execute CQL file +##################################################### +execute_cql_file() { + local cql_file=$1 + local filename=$(basename "${cql_file}") + + print_message "${YELLOW}" "Processing: ${filename}" + + # Execute the CQL file using ycqlsh + set +e # Disable exit on error for this command + ycqlsh "${YCQLSH_HOST}" "${YCQLSH_PORT}" \ + -u "${YCQLSH_USERNAME}" \ + -p "${YCQLSH_PASSWORD}" \ + -f "${cql_file}" >> "${LOG_FILE}" 2>&1 + local exit_code=$? + set -e # Re-enable exit on error + + if [ $exit_code -eq 0 ]; then + print_message "${GREEN}" "✓ SUCCESS: ${filename} executed successfully" + SUCCESSFUL_FILES=$((SUCCESSFUL_FILES + 1)) + else + print_message "${RED}" "✗ FAILED: ${filename} execution failed (exit code: $exit_code)" + FAILED_FILE_LIST+=("${filename}") + FAILED_FILES=$((FAILED_FILES + 1)) + fi + + echo "" +} + +##################################################### +# Main Script +##################################################### + +print_header "YugabyteDB CQL Migration Script - sunbird-lern" + +print_message "${BLUE}" "Configuration:" +echo " Host: ${YCQLSH_HOST}" +echo " Port: ${YCQLSH_PORT}" +echo " Username: ${YCQLSH_USERNAME}" +echo " Script Directory: ${SCRIPT_DIR}" +echo " Log File: ${LOG_FILE}" +echo "" + +# Check if ycqlsh is available +if ! command -v ycqlsh &> /dev/null; then + print_message "${RED}" "ERROR: ycqlsh command not found. Please ensure YugabyteDB client is installed." + exit 1 +fi + +# Test connection to YugabyteDB +print_message "${YELLOW}" "Testing connection to YugabyteDB..." +if ycqlsh "${YCQLSH_HOST}" "${YCQLSH_PORT}" \ + -u "${YCQLSH_USERNAME}" \ + -p "${YCQLSH_PASSWORD}" \ + -e "DESCRIBE KEYSPACES;" >> "${LOG_FILE}" 2>&1; then + print_message "${GREEN}" "✓ Connection successful" + echo "" +else + print_message "${RED}" "✗ Connection failed. Please check your connection parameters." + exit 1 +fi + +# Define the order of execution for CQL files +# sunbird.cql should be executed first as it likely contains keyspace definitions +CQL_FILES=( + "sunbird.cql" + "qmzbm_form_service.cql" + "sunbird_courses.cql" + "sunbird_groups.cql" + "sunbird_notifications.cql" + "sunbird_programs.cql" +) + +print_header "Starting CQL File Execution" + +# Execute each CQL file in order +for cql_file in "${CQL_FILES[@]}"; do + full_path="${SCRIPT_DIR}/${cql_file}" + + if [ -f "${full_path}" ]; then + TOTAL_FILES=$((TOTAL_FILES + 1)) + execute_cql_file "${full_path}" + else + print_message "${YELLOW}" "WARNING: ${cql_file} not found, skipping..." + echo "" + fi +done + +# Print summary +print_header "Migration Summary" + +echo "Total Files Processed: ${TOTAL_FILES}" +echo "Successful: ${SUCCESSFUL_FILES}" +echo "Failed: ${FAILED_FILES}" +echo "" + +if [ ${FAILED_FILES} -gt 0 ]; then + print_message "${RED}" "Failed Files:" + for failed_file in "${FAILED_FILE_LIST[@]}"; do + echo " - ${failed_file}" + done + echo "" + print_message "${RED}" "Migration completed with errors. Check log file: ${LOG_FILE}" + exit 1 +else + print_message "${GREEN}" "All migrations completed successfully!" + print_message "${BLUE}" "Log file: ${LOG_FILE}" +fi + +echo "" +print_message "${BLUE}" "==============================================" diff --git a/scripts/sunbird-yugabyte-migrations/sunbird-lern/qmzbm_form_service.cql b/scripts/sunbird-yugabyte-migrations/sunbird-lern/qmzbm_form_service.cql new file mode 100644 index 000000000..9bcc7e80a --- /dev/null +++ b/scripts/sunbird-yugabyte-migrations/sunbird-lern/qmzbm_form_service.cql @@ -0,0 +1,77 @@ + +CREATE KEYSPACE IF NOT EXISTS qmzbm_form_service WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true; + +CREATE TABLE IF NOT EXISTS qmzbm_form_service.form_data ( + root_org text, + framework text, + type text, + subtype text, + action text, + component text, + created_on timestamp, + data text, + last_modified_on timestamp, + PRIMARY KEY ((root_org, framework, type, subtype, action, component)) +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS qmzbm_form_service.cassandra_migration_version ( + version text PRIMARY KEY, + checksum int, + description text, + execution_time int, + installed_by text, + installed_on timestamp, + installed_rank int, + script text, + success boolean, + type text, + version_rank int +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS qmzbm_form_service.cassandra_migration_version_counts ( + name text PRIMARY KEY, + count counter +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + diff --git a/scripts/sunbird-yugabyte-migrations/sunbird-lern/sunbird.cql b/scripts/sunbird-yugabyte-migrations/sunbird-lern/sunbird.cql new file mode 100644 index 000000000..683e83b31 --- /dev/null +++ b/scripts/sunbird-yugabyte-migrations/sunbird-lern/sunbird.cql @@ -0,0 +1,1832 @@ + +CREATE KEYSPACE IF NOT EXISTS sunbird WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true; + +CREATE TABLE IF NOT EXISTS sunbird.assessment_eval ( + id text PRIMARY KEY, + attemptedcount int, + attemptid text, + contentid text, + courseid text, + createddate text, + result text, + score text, + userid text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_ae_courseid ON sunbird.assessment_eval (courseid); +CREATE INDEX IF NOT EXISTS inx_ae_userid ON sunbird.assessment_eval (userid); +CREATE INDEX IF NOT EXISTS inx_ae_contentid ON sunbird.assessment_eval (contentid); + +CREATE TABLE IF NOT EXISTS sunbird.bulk_upload_process_task ( + processid text, + sequenceid int, + createdon timestamp, + data text, + failureresult text, + iterationid int, + lastupdatedon timestamp, + status int, + successresult text, + PRIMARY KEY (processid, sequenceid) +) WITH CLUSTERING ORDER BY (sequenceid ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.user_roles ( + userid text, + role text, + createdby text, + createddate text, + scope text, + updatedby text, + updateddate text, + PRIMARY KEY (userid, role) +) WITH CLUSTERING ORDER BY (role ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.course_management ( + id text PRIMARY KEY, + addedby text, + addedbyname text, + contentid text, + contenttype text, + courseduration text, + courseid text, + courselogourl text, + coursename text, + courserating text, + coursetype text, + createddate text, + createdfor list, + description text, + enrollementenddate text, + enrollementstartdate text, + facultyid text, + facultyname text, + nooflectures int, + organisationid text, + organisationname text, + publishedby text, + publishedbyname text, + publisheddate text, + status text, + tocurl text, + tutor map, + updatedby text, + updatedbyname text, + updateddate text, + usercount int +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_cm_course_name ON sunbird.course_management (coursename); +CREATE INDEX IF NOT EXISTS inx_cm_courseid ON sunbird.course_management (courseid); +CREATE INDEX IF NOT EXISTS inx_cm_status ON sunbird.course_management (status); +CREATE INDEX IF NOT EXISTS inx_cm_contentid ON sunbird.course_management (contentid); +CREATE INDEX IF NOT EXISTS inx_cm_organisationid ON sunbird.course_management (organisationid); +CREATE INDEX IF NOT EXISTS inx_cm_facultyid ON sunbird.course_management (facultyid); + +CREATE TABLE IF NOT EXISTS sunbird.user_group ( + userid text PRIMARY KEY, + groupid set +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.url_action ( + id text PRIMARY KEY, + name text, + url list +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +// CREATE INDEX IF NOT EXISTS inx_ua_url ON sunbird.url_action (values(url)); +CREATE INDEX IF NOT EXISTS inx_ua_name ON sunbird.url_action (name); + +CREATE TABLE IF NOT EXISTS sunbird.user_auth ( + id text PRIMARY KEY, + createddate text, + source text, + updateddate text, + userid text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_ua_userid ON sunbird.user_auth (userid); +CREATE INDEX IF NOT EXISTS inx_ua_source ON sunbird.user_auth (source); + +CREATE TABLE IF NOT EXISTS sunbird.user_organisation ( + userid text, + organisationid text, + addedby text, + addedbyname text, + approvaldate text, + approvedby text, + associationtype int, + hashtagid text, + id text, + isapproved boolean, + isdeleted boolean, + isrejected boolean, + orgjoindate text, + orgleftdate text, + position text, + roles list, + updatedby text, + updateddate text, + PRIMARY KEY (userid, organisationid) +) WITH CLUSTERING ORDER BY (organisationid ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.user_consent ( + user_id text, + consumer_id text, + object_id text, + categories list, + consent_data text, + consumer_type text, + created_on timestamp, + expiry timestamp, + id text, + last_updated_on timestamp, + object_type text, + status text, + PRIMARY KEY (user_id, consumer_id, object_id) +) WITH CLUSTERING ORDER BY (consumer_id ASC, object_id ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.system_settings ( + id text PRIMARY KEY, + field text, + value text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.client_info ( + id text PRIMARY KEY, + channel text, + clientname text, + createddate text, + masterkey text, + updateddate text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_ci_clientname ON sunbird.client_info (clientname); +CREATE INDEX IF NOT EXISTS inx_ci_clientchannel ON sunbird.client_info (channel); + +CREATE TABLE IF NOT EXISTS sunbird.user ( + id text PRIMARY KEY, + alltncaccepted map, + channel text, + countrycode text, + createdby text, + createddate text, + dob text, + email text, + emailverified boolean, + firstname text, + flagsvalue int, + framework map>>, + isdeleted boolean, + lastname text, + locationids list, + loginid text, + managedby text, + maskedemail text, + maskedphone text, + phone text, + phoneverified boolean, + prevusedemail text, + prevusedphone text, + profiledetails text, + profilelocation text, + profileusertype text, + profileusertypes text, + recoveryemail text, + recoveryphone text, + roles list, + rootorgid text, + status int, + tncacceptedon timestamp, + tncacceptedversion text, + updatedby text, + updateddate text, + userid text, + username text, + usersubtype text, + usertype text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.group_member ( + groupid text, + userid text, + createdby text, + createdon timestamp, + removedby text, + removedon timestamp, + role text, + status text, + updatedby text, + updatedon timestamp, + PRIMARY KEY (groupid, userid) +) WITH CLUSTERING ORDER BY (userid ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS idx_group_member_status ON sunbird.group_member (status); + +CREATE TABLE IF NOT EXISTS sunbird.subject ( + id text PRIMARY KEY, + name text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_sb_name ON sunbird.subject (name); + +CREATE TABLE IF NOT EXISTS sunbird.content_consumption ( + id text PRIMARY KEY, + batchid text, + completedcount int, + contentid text, + contentversion text, + courseid text, + datetime timestamp, + grade text, + lastaccesstime text, + lastcompletedtime text, + lastupdatedtime text, + progress int, + result text, + score text, + status int, + userid text, + viewcount int +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_cc_contentid ON sunbird.content_consumption (contentid); +CREATE INDEX IF NOT EXISTS inx_cc_courseid ON sunbird.content_consumption (courseid); +CREATE INDEX IF NOT EXISTS inx_cc_status ON sunbird.content_consumption (status); +CREATE INDEX IF NOT EXISTS inx_cc_userid ON sunbird.content_consumption (userid); + +CREATE TABLE IF NOT EXISTS sunbird.group ( + id text PRIMARY KEY, + activities list>>, + createdby text, + createdon timestamp, + description text, + membershiptype text, + name text, + status text, + updatedby text, + updatedon timestamp +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS idx_group_status ON sunbird.group (status); + +CREATE TABLE IF NOT EXISTS sunbird.user_lookup ( + type text, + value text, + userid text, + PRIMARY KEY ((type, value)) +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.role_group ( + id text PRIMARY KEY, + name text, + url_action_ids list +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.organisation ( + id text PRIMARY KEY, + channel text, + contactdetail text, + createdby text, + createddate text, + description text, + email text, + externalid text, + hashtagid text, + homeurl text, + imgurl text, + isrootorg boolean, + isssoenabled boolean, + istenant boolean, + keys map>>, + locationids list, + organisationsubtype int, + organisationtype int, + orglocation text, + orgname text, + provider text, + rootorgid text, + slug text, + status int, + updatedby text, + updateddate text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.assessment_item ( + id text PRIMARY KEY, + answers text, + assessmentitemid text, + assessmenttype text, + attempteddate text, + attemptid text, + contentid text, + courseid text, + createddate text, + evaluationstatus boolean, + maxscore text, + processingstatus boolean, + result text, + score text, + timetaken int, + userid text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_ai_contentid ON sunbird.assessment_item (contentid); +CREATE INDEX IF NOT EXISTS inx_ai_userid ON sunbird.assessment_item (userid); +CREATE INDEX IF NOT EXISTS inx_ai_assessmentitemid ON sunbird.assessment_item (assessmentitemid); +CREATE INDEX IF NOT EXISTS inx_ai_courseid ON sunbird.assessment_item (courseid); + +CREATE TABLE IF NOT EXISTS sunbird.user_badge_assertion ( + id text PRIMARY KEY, + assertionid text, + badgeclassimage text, + badgeclassname text, + badgeid text, + createdts timestamp, + issuerid text, + userid text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.user_skills ( + id text PRIMARY KEY, + createdby text, + createdon timestamp, + endorsementcount int, + endorserslist frozen>>>, + lastupdatedby text, + lastupdatedon timestamp, + skillname text, + skillnametolowercase text, + userid text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_us_userid ON sunbird.user_skills (userid); + +CREATE TABLE IF NOT EXISTS sunbird.geo_location ( + id text PRIMARY KEY, + createdby text, + createddate text, + location text, + rootorgid text, + topic text, + type text, + updatedby text, + updateddate text, + usercount int, + usercountttl text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_gl_rootorgid ON sunbird.geo_location (rootorgid); + +CREATE TABLE IF NOT EXISTS sunbird.role ( + id text PRIMARY KEY, + name text, + rolegroupid list, + status int +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.location ( + id text PRIMARY KEY, + code text, + name text, + parentid text, + type text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.user_org ( + id text PRIMARY KEY, + addedby text, + addedbyname text, + approvaldate text, + approvedby text, + hashtagid text, + isapproved boolean, + isdeleted boolean, + isrejected boolean, + organisationid text, + orgjoindate text, + orgleftdate text, + position text, + roles list, + updatedby text, + updateddate text, + userid text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_uorg_userid ON sunbird.user_org (userid); +CREATE INDEX IF NOT EXISTS inx_uorg_orgid ON sunbird.user_org (organisationid); + +CREATE TABLE IF NOT EXISTS sunbird.media_type ( + id text PRIMARY KEY, + name text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.badge ( + id text PRIMARY KEY, + description text, + isactive boolean, + name text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.master_action ( + id text PRIMARY KEY, + name text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_ma_name ON sunbird.master_action (name); + +CREATE TABLE IF NOT EXISTS sunbird.badge_class_extension ( + id text PRIMARY KEY, + issuerid text, + roles list, + rootorgid text, + subtype text, + type text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.cassandra_migration_version ( + version text PRIMARY KEY, + checksum int, + description text, + execution_time int, + installed_by text, + installed_on timestamp, + installed_rank int, + script text, + success boolean, + type text, + version_rank int +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.page_management ( + id text PRIMARY KEY, + appmap text, + created_date timestamp, + createdby text, + createddate text, + name text, + organisationid text, + portalmap text, + updated_date timestamp, + updatedby text, + updateddate text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.course_enrollment ( + id text PRIMARY KEY, + active boolean, + addedby text, + contentid text, + courseid text, + courselogourl text, + coursename text, + datetime timestamp, + delta text, + description text, + enrolleddate text, + grade text, + lastreadcontentid text, + lastreadcontentstatus int, + progress int, + status int, + tocurl text, + userid text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_ce_userid ON sunbird.course_enrollment (userid); +CREATE INDEX IF NOT EXISTS inx_ce_course_name ON sunbird.course_enrollment (coursename); +CREATE INDEX IF NOT EXISTS inx_ce_status ON sunbird.course_enrollment (status); +CREATE INDEX IF NOT EXISTS inx_ce_courseid ON sunbird.course_enrollment (courseid); + +CREATE TABLE IF NOT EXISTS sunbird.org_external_identity ( + provider text, + externalid text, + orgid text, + PRIMARY KEY (provider, externalid) +) WITH CLUSTERING ORDER BY (externalid ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.email_template ( + name text PRIMARY KEY, + createdby text, + createdon timestamp, + lastupdatedby text, + lastupdatedon timestamp, + template text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.usr_external_identity ( + provider text, + idtype text, + externalid text, + createdby text, + createdon timestamp, + lastupdatedby text, + lastupdatedon timestamp, + originalexternalid text, + originalidtype text, + originalprovider text, + userid text, + PRIMARY KEY (provider, idtype, externalid) +) WITH CLUSTERING ORDER BY (idtype ASC, externalid ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_usrextid_user_id ON sunbird.usr_external_identity (userid); + +CREATE TABLE IF NOT EXISTS sunbird.tenant_preference_v2 ( + orgid text, + key text, + createdby text, + createdon timestamp, + data text, + updatedby text, + updatedon timestamp, + PRIMARY KEY (orgid, key) +) WITH CLUSTERING ORDER BY (key ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.cert_registry ( + id text PRIMARY KEY, + accesscode text, + createdat timestamp, + createdby text, + data text, + isrevoked boolean, + jsonurl text, + pdfurl text, + reason text, + recipient text, + related text, + updatedat timestamp, + updatedby text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.user_job_profile ( + id text PRIMARY KEY, + addressid text, + boardname text, + createdby text, + createddate text, + enddate text, + iscurrentjob boolean, + isdeleted boolean, + isrejected boolean, + isverified boolean, + jobname text, + joiningdate text, + orgid text, + orgname text, + role text, + subject list, + updatedby text, + updateddate text, + userid text, + verifiedby text, + verifieddate text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_ujp_userid ON sunbird.user_job_profile (userid); + +CREATE TABLE IF NOT EXISTS sunbird.user_declarations ( + userid text, + orgid text, + persona text, + createdby text, + createdon timestamp, + errortype text, + status text, + updatedby text, + updatedon timestamp, + userinfo map, + PRIMARY KEY (userid, orgid, persona) +) WITH CLUSTERING ORDER BY (orgid ASC, persona ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.bulk_upload_process ( + id text PRIMARY KEY, + createdby text, + createdon timestamp, + data text, + failureresult text, + lastupdatedon timestamp, + objecttype text, + organisationid text, + processendtime text, + processstarttime text, + retrycount int, + status int, + storagedetails text, + successresult text, + taskcount int, + telemetrycontext map, + uploadedby text, + uploadeddate text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_status ON sunbird.bulk_upload_process (status); + +CREATE TABLE IF NOT EXISTS sunbird.address ( + id text PRIMARY KEY, + addressline1 text, + addressline2 text, + addtype text, + city text, + country text, + createdby text, + createddate text, + isdeleted boolean, + state text, + updatedby text, + updateddate text, + userid text, + zipcode text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.otp ( + type text, + key text, + attemptedcount int, + createdon timestamp, + otp text, + PRIMARY KEY (type, key) +) WITH CLUSTERING ORDER BY (key ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.report_tracking ( + id text PRIMARY KEY, + createddate text, + data text, + email text, + fileurl text, + firstname text, + format text, + period text, + resourceid text, + resourcename text, + status int, + trycount int, + type text, + updateddate text, + uploadeddate text, + userid text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_report_tracking_userid ON sunbird.report_tracking (userid); +CREATE INDEX IF NOT EXISTS inx_report_tracking_status ON sunbird.report_tracking (status); + +CREATE TABLE IF NOT EXISTS sunbird.user_external_identity ( + id text PRIMARY KEY, + createdby text, + createdon timestamp, + externalid text, + lastupdatedby text, + lastupdatedon timestamp, + provider text, + userid text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_uei_userid ON sunbird.user_external_identity (userid); +CREATE INDEX IF NOT EXISTS inx_uei_externalid ON sunbird.user_external_identity (externalid); +CREATE INDEX IF NOT EXISTS inx_uei_provider ON sunbird.user_external_identity (provider); + +CREATE TABLE IF NOT EXISTS sunbird.user_courses ( + id text PRIMARY KEY, + active boolean, + addedby text, + batchid text, + completedon timestamp, + contentid text, + courseid text, + courselogourl text, + coursename text, + datetime timestamp, + delta text, + description text, + enrolleddate text, + grade text, + lastreadcontentid text, + lastreadcontentstatus int, + leafnodescount int, + processingstatus text, + progress int, + status int, + tocurl text, + userid text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_ucs_batchid ON sunbird.user_courses (batchid); +CREATE INDEX IF NOT EXISTS inx_ucs_courseid ON sunbird.user_courses (courseid); +CREATE INDEX IF NOT EXISTS inx_ucs_status ON sunbird.user_courses (status); +CREATE INDEX IF NOT EXISTS inx_ucs_course_name ON sunbird.user_courses (coursename); +CREATE INDEX IF NOT EXISTS inx_ucs_userid ON sunbird.user_courses (userid); + +CREATE TABLE IF NOT EXISTS sunbird.tenant_preference ( + id text PRIMARY KEY, + data text, + key text, + orgid text, + role text, + tenantname text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_tp_key ON sunbird.tenant_preference (key); +CREATE INDEX IF NOT EXISTS inx_tp_userid ON sunbird.tenant_preference (orgid); + +CREATE TABLE IF NOT EXISTS sunbird.shadow_user ( + channel text, + userextid text, + addedby text, + attemptedcount int, + claimedon timestamp, + claimstatus int, + createdon timestamp, + email text, + name text, + orgextid text, + phone text, + processid text, + updatedon timestamp, + userid text, + userids list, + userstatus int, + PRIMARY KEY (channel, userextid) +) WITH CLUSTERING ORDER BY (userextid ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_shausr_userextid ON sunbird.shadow_user (userextid); +CREATE INDEX IF NOT EXISTS inx_shausr_userstatus ON sunbird.shadow_user (userstatus); +// CREATE INDEX IF NOT EXISTS shadow_user_userids_idx ON sunbird.shadow_user (values(userids)); +CREATE INDEX IF NOT EXISTS inx_shausr_claimstatus ON sunbird.shadow_user (claimstatus); +CREATE INDEX IF NOT EXISTS inx_shausr_userid ON sunbird.shadow_user (userid); +CREATE INDEX IF NOT EXISTS inx_shausr_processid ON sunbird.shadow_user (processid); +CREATE INDEX IF NOT EXISTS inx_shausr_orgextid ON sunbird.shadow_user (orgextid); + +CREATE TABLE IF NOT EXISTS sunbird.user_action_role ( + id text PRIMARY KEY, + actiongroupid list, + roleid text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.user_cert ( + id text PRIMARY KEY, + accesscode text, + createdat timestamp, + isdeleted boolean, + oldid text, + store map, + updatedat timestamp, + userid text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_usrcert_user_id ON sunbird.user_cert (userid); + +CREATE TABLE IF NOT EXISTS sunbird.cassandra_migration_version_counts ( + name text PRIMARY KEY, + count counter +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.skills ( + id text PRIMARY KEY, + skills list +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.user_feed ( + id text PRIMARY KEY, + category text, + createdby text, + createdon timestamp, + data text, + expireon timestamp, + priority int, + status text, + updatedby text, + updatedon timestamp, + userid text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS user_feed_category_idx ON sunbird.user_feed (category); +CREATE INDEX IF NOT EXISTS user_feed_userid_idx ON sunbird.user_feed (userid); + +CREATE TABLE IF NOT EXISTS sunbird.rate_limit ( + key text, + unit text, + count int, + rate int, + PRIMARY KEY (key, unit) +) WITH CLUSTERING ORDER BY (unit ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.course_publish_status ( + id text PRIMARY KEY, + status int, + submitdate text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_cps_status ON sunbird.course_publish_status (status); + +CREATE TABLE IF NOT EXISTS sunbird.action_group ( + id text PRIMARY KEY, + actionid list, + groupname text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.course_batch ( + id text PRIMARY KEY, + countdecrementdate text, + countdecrementstatus boolean, + countincrementdate text, + countincrementstatus boolean, + courseadditionalinfo map, + coursecreator text, + courseid text, + createdby text, + createddate text, + createdfor list, + description text, + enddate text, + enrollmentenddate text, + enrollmenttype text, + hashtagid text, + mentors list, + name text, + startdate text, + status int, + updateddate text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_cou_bat_coursecreator ON sunbird.course_batch (coursecreator); +CREATE INDEX IF NOT EXISTS inx_cou_bat_courseid ON sunbird.course_batch (courseid); +CREATE INDEX IF NOT EXISTS inx_cou_bat_status ON sunbird.course_batch (status); +CREATE INDEX IF NOT EXISTS inx_cou_bat_createdby ON sunbird.course_batch (createdby); +CREATE INDEX IF NOT EXISTS inx_cou_bat_enrolmenttype ON sunbird.course_batch (enrollmenttype); + +CREATE TABLE IF NOT EXISTS sunbird.user_notes ( + id text PRIMARY KEY, + contentid text, + courseid text, + createdby text, + createddate text, + isdeleted boolean, + note text, + tags list, + title text, + updatedby text, + updateddate text, + userid text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.user_education ( + id text PRIMARY KEY, + addressid text, + boardoruniversity text, + coursename text, + createdby text, + createddate text, + degree text, + duration int, + grade text, + isdeleted boolean, + name text, + percentage double, + updatedby text, + updateddate text, + userid text, + yearofpassing int +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_ueu_userid ON sunbird.user_education (userid); + +CREATE TABLE IF NOT EXISTS sunbird.content_badge_association ( + id text PRIMARY KEY, + badgeclassimage text, + badgeclassname text, + badgeid text, + contentid text, + createdby text, + createdon timestamp, + issuerid text, + lastupdatedby text, + lastupdatedon timestamp, + status int +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird.user_badge ( + id text PRIMARY KEY, + badgetypeid text, + createdby text, + createddate text, + description text, + expirydate text, + image text, + isexpired boolean, + isrevoked boolean, + isverified boolean, + provideremail text, + providerid text, + providername text, + providerphone text, + receiveddate text, + receiverid text, + revocationdate text, + revocationreason text, + revokedby text, + updatedby text, + updateddate text, + validitydate int, + verifiedby text, + verifieddate text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_usr_badg_receiverid ON sunbird.user_badge (receiverid); +CREATE INDEX IF NOT EXISTS inx_usr_badg ON sunbird.user_badge (badgetypeid); + +CREATE TABLE IF NOT EXISTS sunbird.config_path_audit ( + id text, + cloud_store_type text, + created_date bigint, + cloud_store_account text, + cloud_store_container text, + cloud_store_path text, + version bigint, + PRIMARY KEY ((id, cloud_store_type), created_date) +) WITH CLUSTERING ORDER BY (created_date DESC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_created_date ON sunbird.config_path_audit (created_date); + +CREATE TABLE IF NOT EXISTS sunbird.page_section ( + id text PRIMARY KEY, + alt text, + created_date timestamp, + createdby text, + createddate text, + datasource text, + description text, + display text, + dynamicfilters text, + imgurl text, + name text, + searchquery text, + sectiondatatype text, + status int, + updated_date timestamp, + updatedby text, + updateddate text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + diff --git a/scripts/sunbird-yugabyte-migrations/sunbird-lern/sunbird_courses.cql b/scripts/sunbird-yugabyte-migrations/sunbird-lern/sunbird_courses.cql new file mode 100644 index 000000000..1989c7670 --- /dev/null +++ b/scripts/sunbird-yugabyte-migrations/sunbird-lern/sunbird_courses.cql @@ -0,0 +1,374 @@ + +CREATE KEYSPACE IF NOT EXISTS sunbird_courses WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true; + +CREATE TYPE IF NOT EXISTS sunbird_courses.question ( + id text, + assess_ts timestamp, + max_score double, + score double, + type text, + title text, + resvalues frozen>>>, + params frozen>>>, + description text, + duration decimal +); + +CREATE TABLE IF NOT EXISTS sunbird_courses.content_consumption ( + userid text, + contentid text, + batchid text, + courseid text, + completedcount int, + contentversion text, + datetime timestamp, + grade text, + lastaccesstime text, + lastcompletedtime text, + lastupdatedtime text, + progress int, + result text, + score text, + status int, + viewcount int, + PRIMARY KEY (userid, contentid, batchid, courseid) +) WITH CLUSTERING ORDER BY (contentid ASC, batchid ASC, courseid ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_cc_status ON sunbird_courses.content_consumption (status); + +CREATE TABLE IF NOT EXISTS sunbird_courses.cassandra_migration_version ( + version text PRIMARY KEY, + checksum int, + description text, + execution_time int, + installed_by text, + installed_on timestamp, + installed_rank int, + script text, + success boolean, + type text, + version_rank int +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird_courses.user_activity_agg ( + activity_type text, + activity_id text, + user_id text, + context_id text, + agg map, + agg_details list, + agg_last_updated map, + aggregates map, + PRIMARY KEY ((activity_type, activity_id, user_id), context_id) +) WITH CLUSTERING ORDER BY (context_id ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird_courses.report_user_enrolments ( + batchid text, + courseid text, + userid text, + active boolean, + addedby text, + certificates frozen>>>, + certstatus int, + completedon timestamp, + completionpercentage int, + contentstatus frozen>, + datetime timestamp, + enrolled_date timestamp, + enrolleddate text, + issued_certificates frozen>>>, + lastcontentaccesstime timestamp, + lastreadcontentid text, + lastreadcontentstatus int, + progress int, + status int, + PRIMARY KEY (batchid, courseid, userid) +) WITH CLUSTERING ORDER BY (courseid ASC, userid ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'enabled': 'false', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird_courses.assessment_aggregator ( + course_id text, + batch_id text, + user_id text, + content_id text, + attempt_id text, + created_on timestamp, + grand_total text, + last_attempted_on timestamp, + question list>, + total_max_score double, + total_score double, + updated_on timestamp, + PRIMARY KEY (course_id, batch_id, user_id, content_id, attempt_id) +) WITH CLUSTERING ORDER BY (batch_id ASC, user_id ASC, content_id ASC, attempt_id ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird_courses.course_batch ( + courseid text, + batchid text, + cert_templates map>>, + created_date timestamp, + createdby text, + createddate text, + createdfor list, + description text, + end_date timestamp, + enddate text, + enrollment_enddate timestamp, + enrollmentenddate text, + enrollmenttype text, + mentors list, + name text, + start_date timestamp, + startdate text, + status int, + tandc boolean, + updated_date timestamp, + updateddate text, + PRIMARY KEY (courseid, batchid) +) WITH CLUSTERING ORDER BY (batchid ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird_courses.cassandra_migration_version_counts ( + name text PRIMARY KEY, + count counter +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird_courses.user_enrolments ( + userid text, + courseid text, + batchid text, + active boolean, + addedby text, + certificates list>>, + certstatus int, + completedon timestamp, + completionpercentage int, + contentstatus map, + datetime timestamp, + enrolled_date timestamp, + enrolleddate text, + issued_certificates list>>, + lastcontentaccesstime timestamp, + lastreadcontentid text, + lastreadcontentstatus int, + progress int, + status int, + PRIMARY KEY (userid, courseid, batchid) +) WITH CLUSTERING ORDER BY (courseid ASC, batchid ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird_courses.bulk_upload_process ( + id text PRIMARY KEY, + data text, + failureresult text, + objecttype text, + processendtime text, + processstarttime text, + status int, + successresult text, + uploadedby text, + uploadeddate text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_bup_status ON sunbird_courses.bulk_upload_process (status); + +CREATE TABLE IF NOT EXISTS sunbird_courses.user_content_consumption ( + userid text, + courseid text, + batchid text, + contentid text, + completedcount int, + completionpercentage float, + datetime timestamp, + last_access_time timestamp, + last_completed_time timestamp, + last_updated_time timestamp, + lastaccesstime text, + lastcompletedtime text, + lastupdatedtime text, + progress int, + progressdetails text, + status int, + viewcount int, + PRIMARY KEY (userid, courseid, batchid, contentid) +) WITH CLUSTERING ORDER BY (courseid ASC, batchid ASC, contentid ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird_courses.user_courses ( + batchid text, + userid text, + active boolean, + addedby text, + certificates list>>, + completedon timestamp, + completionpercentage int, + contentstatus map, + courseid text, + datetime timestamp, + delta text, + enrolleddate text, + grade text, + lastreadcontentid text, + lastreadcontentstatus int, + progress int, + status int, + PRIMARY KEY (batchid, userid) +) WITH CLUSTERING ORDER BY (userid ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS inx_ucs_status ON sunbird_courses.user_courses (status); + diff --git a/scripts/sunbird-yugabyte-migrations/sunbird-lern/sunbird_groups.cql b/scripts/sunbird-yugabyte-migrations/sunbird-lern/sunbird_groups.cql new file mode 100644 index 000000000..f0646bc9a --- /dev/null +++ b/scripts/sunbird-yugabyte-migrations/sunbird-lern/sunbird_groups.cql @@ -0,0 +1,128 @@ + +CREATE KEYSPACE IF NOT EXISTS sunbird_groups WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true; + +CREATE TABLE IF NOT EXISTS sunbird_groups.cassandra_migration_version ( + version text PRIMARY KEY, + checksum int, + description text, + execution_time int, + installed_by text, + installed_on timestamp, + installed_rank int, + script text, + success boolean, + type text, + version_rank int +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird_groups.cassandra_migration_version_counts ( + name text PRIMARY KEY, + count counter +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird_groups.group ( + id text PRIMARY KEY, + activities list>>, + createdby text, + createdon timestamp, + description text, + membershiptype text, + name text, + status text, + updatedby text, + updatedon timestamp +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS idx_group_status ON sunbird_groups.group (status); + +CREATE TABLE IF NOT EXISTS sunbird_groups.group_member ( + groupid text, + userid text, + createdby text, + createdon timestamp, + removedby text, + removedon timestamp, + role text, + status text, + updatedby text, + updatedon timestamp, + visited boolean, + PRIMARY KEY (groupid, userid) +) WITH CLUSTERING ORDER BY (userid ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +CREATE INDEX IF NOT EXISTS idx_group_member_status ON sunbird_groups.group_member (status); + +CREATE TABLE IF NOT EXISTS sunbird_groups.user_group ( + userid text PRIMARY KEY, + groupid set +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + diff --git a/scripts/sunbird-yugabyte-migrations/sunbird-lern/sunbird_notifications.cql b/scripts/sunbird-yugabyte-migrations/sunbird-lern/sunbird_notifications.cql new file mode 100644 index 000000000..df702af73 --- /dev/null +++ b/scripts/sunbird-yugabyte-migrations/sunbird-lern/sunbird_notifications.cql @@ -0,0 +1,148 @@ + +CREATE KEYSPACE IF NOT EXISTS sunbird_notifications WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true; + +CREATE TABLE IF NOT EXISTS sunbird_notifications.cassandra_migration_version ( + version text PRIMARY KEY, + checksum int, + description text, + execution_time int, + installed_by text, + installed_on timestamp, + installed_rank int, + script text, + success boolean, + type text, + version_rank int +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird_notifications.notification_feed ( + userid text, + id text, + action text, + category text, + createdby text, + createdon timestamp, + expireon timestamp, + priority int, + status text, + updatedby text, + updatedon timestamp, + version text, + PRIMARY KEY (userid, id) +) WITH CLUSTERING ORDER BY (id ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird_notifications.action_template ( + action text PRIMARY KEY, + templateid text, + type text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird_notifications.cassandra_migration_version_counts ( + name text PRIMARY KEY, + count counter +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird_notifications.notification_template ( + templateid text PRIMARY KEY, + config map, + createdby text, + createdon timestamp, + data text, + lastupdatedby text, + lastupdatedon timestamp, + template_schema text, + type text, + ver text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird_notifications.feed_version_map ( + id text PRIMARY KEY, + feedid text, + status text +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + diff --git a/scripts/sunbird-yugabyte-migrations/sunbird-lern/sunbird_programs.cql b/scripts/sunbird-yugabyte-migrations/sunbird-lern/sunbird_programs.cql new file mode 100644 index 000000000..db53a9b07 --- /dev/null +++ b/scripts/sunbird-yugabyte-migrations/sunbird-lern/sunbird_programs.cql @@ -0,0 +1,81 @@ + +CREATE KEYSPACE IF NOT EXISTS sunbird_programs WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true; + +CREATE TABLE IF NOT EXISTS sunbird_programs.cassandra_migration_version ( + version text PRIMARY KEY, + checksum int, + description text, + execution_time int, + installed_by text, + installed_on timestamp, + installed_rank int, + script text, + success boolean, + type text, + version_rank int +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird_programs.cassandra_migration_version_counts ( + name text PRIMARY KEY, + count counter +) WITH bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; + +CREATE TABLE IF NOT EXISTS sunbird_programs.program_enrollment ( + program_id text, + user_id text, + created_at date, + organisation_id text, + organisation_name text, + pii_consent_required boolean, + program_externalid text, + program_name text, + updated_at date, + user_locations map, + user_sub_type text, + user_type text, + PRIMARY KEY (program_id, user_id) +) WITH CLUSTERING ORDER BY (user_id ASC) + AND bloom_filter_fp_chance = 0.01 + AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} + AND comment = '' + AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} + AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} + AND crc_check_chance = 1.0 + AND dclocal_read_repair_chance = 0.1 + AND default_time_to_live = 0 + AND gc_grace_seconds = 864000 + AND max_index_interval = 2048 + AND memtable_flush_period_in_ms = 0 + AND min_index_interval = 128 + AND read_repair_chance = 0.0 + AND speculative_retry = '99PERCENTILE' + AND transactions = {'enabled': 'true'}; +