updated query to work with any redmine database.