This seems pretty inefficient, as it incurs a join for every insert. We should be able to just pass in the catalog_id as an argument to the function and just use that. The caller should know exactly which catalog these resources apply to (as they're already passing in the catalog-hash)...we should just swap that to use the id instead.