Querying the migrate database from custom code