def validate_migration_process(
migration_process: domain_migration.MigrationProcess,
ctx: domain_context.MigrationContext,
) -> None:
if migration_process.has_rules():
_LOGGER.info(
"Starting validation of migration process with version %s...",
migration_process.migration_version,
)
for rule in migration_process.rules:
if not rule.is_independent():
validate_rule_dependencies_recursive(
ctx=ctx,
depends_on=rule.depends_on,
)
if rule.check_is_broken(ctx):
_LOGGER.error("%s rule failed, raising...", rule.name)
raise domain_exception.MigrationBusinessRuleBrokenError(rule)
_LOGGER.info("%s rule successfully passed.", rule.name)