Use SQL to determine current roles

This refers to fb29b87, which was doing the current role selection in Ruby.