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

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

(defn get-connection [hosts keyspace]
  (alia/connect (alia/cluster {:contact-points hosts}) keyspace))

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

             (map :id))))))

(defn- ->CassDatabase [target]
  (map->CassandraDatabase (:db target)))

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