 
   For example, if the source of an edge is {'type' 'Foo' 'title' 'bar'},
   then we'll lookup a resource with that key and use its hash."
-  [catalog-hash edges refs-to-hashes]
-  {:pre [(string? catalog-hash)
+  [catalog-id edges refs-to-hashes]
+  {:pre [(number? catalog-id)
          (coll? edges)
          (map? refs-to-hashes)]}
-  (let [the-sql "INSERT INTO edges (catalog_id,source,target,type) SELECT id,?,?,? FROM catalogs WHERE hash=?"
+  (let [the-sql "INSERT INTO edges (catalog_id,source,target,type) VALUES (?,?,?,?)"
         rows    (for [{:keys [source target relationship]} edges
                       :let [source-hash (refs-to-hashes source)
                             target-hash (refs-to-hashes target)
                             type        (name relationship)]]
-                  [source-hash target-hash type catalog-hash])]
+                  [catalog-id source-hash target-hash type])]
     (apply sql/do-prepared the-sql rows)))
 
 (defn add-catalog!


              (when-not exists?
                (inc! (:new-catalog metrics))
                (add-catalog-metadata! hash api-version version transaction-uuid)
                (let [refs-to-hashes (zipmap (keys resources) resource-hashes)]
                  (time! (:add-resources metrics)
                         (add-resources! hash resources refs-to-hashes))
                  (time! (:add-edges metrics)
                         (add-edges! hash edges refs-to-hashes))))))

           hash)))


  1. Each key corresponds to a table, and each value is a list of rows
  2. The mapping of keys and values to table names and columns is done
     by `add-resources!`"
  [catalog-id {:keys [type title exported parameters tags file line] :as resource} resource-hash persisted?]
  {:pre  [(number? catalog-id)
          (every? string? #{type title})]
   :post [(= (set (keys %)) #{:resource :parameters :parameters_cache})]}
  (let [values {:resource         [[catalog-id resource-hash type title (sutils/to-jdbc-varchar-array tags) exported file line]]
                :parameters       []
                :parameters_cache []}]

