                                    (hayt/where {:id id}))))))
 
   (applied-migration-ids [db]
-    (with-connection hosts keyspace
+    (with-connection db
       (fn [conn]
         (ensure-migration-schema conn)
         (->> (alia/execute conn

             (map :id))))))

(defn- ->CassDatabase [target]
  (map->CassandraDatabase (select-keys (:db target) [:hosts :keyspace])))

;; ============================================================================
;; Joplin interface

                                                             :created_at  :timestamp
                                                             :primary-key [:id]}))))

(defn- cluster-configuration
  [{:keys [hosts credentials] :as cass-db}]
  {:contact-points hosts
   :credentials credentials})

(defn get-connection [db]
  (alia/connect (alia/cluster (cluster-configuration db)) (:keyspace db)))

(defn with-connection [db f]
  (when-let [conn (get-connection db)]
    (try
      (f conn)
      (finally (alia/shutdown conn)))))
