def raise_if_migrations_checksum_mismatch(event: domain_event.ApplicationEvent) -> None:
service = migration_service.MigrationService(event.application.session)
for migration in event.application.session.get_all_migration_models():
current_migration_state = service.get_migration(migration.name, migration.version)
if current_migration_state.checksum != migration.checksum:
_LOGGER.error(
"%s: migration file '%s' with version %s is changed, raising...",
raise_if_migrations_checksum_mismatch.__name__,
migration.name,
migration.version,
)
raise domain_exception.MigrationFileChangedError(
migration_name=migration.name,
migration_version=migration.version,
)