Move this to its appropriate place
Because `get_metadata()` is lossy, roll our own SQL queries