HyperSec XDR Data Engine

Schema Updates

Schema Planning and Validation

Before applying schema modifications, it is recommended to run a schema planning phase to preview changes and validate their correctness.

Schema Planning Steps:

  1. Run Schema Plan Command: * Generate a schema plan to preview the changes before applying them. * Review the generated plan to ensure all modifications are correct. * Validate the logs in the xdr-s-* file.

Command:

poetry run xdrcli plan-schemas \
  --xdr_package_file_path /path/to/xdr_package.yaml \
  --xdr_root_log_path /path/to/logs \
  --target production \
  --target_file_path /path/to/xdr_targets.yaml

Options:

Schema Modification Process

Updating Order By/Primary Key

Objective:

Steps:

  1. Run Apply Schema Command: * Use the schema update command to create a replacement table with updated primary key and ORDER BY columns. * The command will handle the creation of a new table with the updated schema, replacement of the old table, and validation of data migration. * The command will also handle the addition of new indexes, removal of old indexes, and validation of changes.

Command:

poetry run xdrcli apply-schemas \
  --xdr_package_file_path /path/to/xdr_package.yaml \
  --schema_update_flag YES \
  --xdr_root_log_path /path/to/logs \
  --target production \
  --target_file_path /path/to/xdr_targets.yaml

Options:

Implementation Details

The schema modification process involves a series of steps to ensure data integrity and minimal downtime. The SchemaModifier class handles the entire schema evolution process, including reading schema files, creating replacement tables, and validating data migration. It utilizes the xdrcli commands for schema planning and updates, providing detailed logging for monitoring the schema modification process.

Key Functions:

Error Handling and Logging

Best Practices: