Database script to clean out orphaned memberships