def migrate_secret_key(old_key):
    """Call entry points exposed for the SECRET_KEY change."""
    if 'SECRET_KEY' not in current_app.config or \
            current_app.config['SECRET_KEY'] is None:
        raise click.ClickException(
            'SECRET_KEY is not set in the configuration.')

    for ep in iter_entry_points('invenio_base.secret_key'):
        try:
            ep.load()(old_key=old_key)
        except Exception:
            current_app.logger.error(
                'Failed to initialize entry point: {0}'.format(ep))
            raise
    click.secho('Successfully changed secret key.', fg='green')
Call entry points exposed for the SECRET_KEY change.