def METHOD_NAME(error_message, from_beginning):
    """Restart all the workflows in ERROR matching the given error message."""
    errors = WorkflowObjectModel.query.filter_by(status=ObjectStatus.ERROR).all()
    to_restart = [e.id for e in errors if error_message in e.extra_data['_error_msg']]
    click.secho("Found {} workflows to restart from {}".format(
        len(to_restart),
        "first step" if from_beginning else "current step"
    ))
    for wf_id in to_restart:
        obj = workflow_object_class.get(wf_id)
        if from_beginning:
            obj.callback_pos = [0]
            obj.status = ObjectStatus.INITIAL
        else:
            obj.status = ObjectStatus.RUNNING
        obj.save()
        db.session.commit()
        obj.continue_workflow('restart_task', True)
        click.secho("Workflow {} restarted successfully".format(wf_id))