def METHOD_NAME(principals, get_event):
    role_attrs = get_simple_column_attrs(EventRole) | {'members'}
    for p in principals:
        click.echo(f'Fixing {p}')
        event = get_event(p)
        try:
            event_role = [r for r in event.roles if r.code == p.event_role.code][0]
        except IndexError:
            event_role = EventRole(event=event)
            event_role.populate_from_attrs(p.event_role, role_attrs)
        else:
            click.echo(f'  using existing role {event_role}')
        p.event_role = event_role
    db.session.flush()