 (defn init-with-db
   "Performs all initialization operations requiring a database
   connection using a transient connection pool derived from the
-  `write-db-config`.  Blocks until the initialization is complete, and
+  db-config.  Blocks until the initialization is complete, and
   then returns an unspecified value.  Throws exceptions on errors.
   Throws {:kind ::unsupported-database :current version :oldest
   version} if the current database is not supported. Throws
   {:kind ::invalid-database-configuration :failed-validation failed-map}
   if the database contains a disallowed setting."
-  [write-db-config config]
+  [db-name db-config]
   ;; A C-c (SIGINT) will close the pool via the shutdown hook, which
   ;; will then cause the pool connection to throw a (generic)
   ;; SQLException.
-  (let  [migrator (:migrator-username write-db-config)]
-    (with-open [db-pool (-> (assoc write-db-config
-                                   :pool-name "PDBMigrationsPool"
+  (log/info (trs "Ensuring {0} database is up to date" name))
+  (let  [migrator (:migrator-username db-config)]
+    (with-open [db-pool (-> (assoc db-config
+                                   :pool-name (if db-name
+                                                (str "PDBMigrationsPool: " db-name)
+                                                "PDBMigrationsPool")
                                    :connection-timeout 3000
                                    :rewrite-batched-inserts "true"
                                    :user migrator
-                                   :password (:migrator-password write-db-config))
+                                   :password (:migrator-password db-config))
                             (jdbc/make-connection-pool database-metrics-registry))]
       (let [runtime (Runtime/getRuntime)
             on-shutdown (doto (Thread.

;; FIXME: with-logged-ex...

(defn coordinate-gc-with-shutdown
  [write-db clean-lock database request stop-status]
  ;; This function assumes it will never be called concurrently with
  ;; itself, so that it's ok to just conj/disj below, instead of
  ;; tracking an atomic count or similar.

                     (first supported))))
    meta))

(defn require-valid-db-server
  [min-version-override]
  (verify-database-version min-version-override)
  (verify-database-settings (request-database-settings)))

(defn require-current-schema
  [msg]
  (require-valid-schema)
  (when-let [pending (seq (pending-migrations))]
    (let [m (str msg (trs "  Missing migrations: {0}" (mapv first pending)))]
      (throw (ex-info m {:kind ::migration-required
                         :pending pending})))))

(defn require-valid-db [min-version-override]
  (require-valid-db-server min-version-override)
  (require-current-schema (trs "Database is not fully migrated.")))

(defn prep-db
  [{:keys [username migrator-username migrate min-required-version]}]
  (require-valid-db-server min-required-version)
  (if migrate
    (if (= username migrator-username)
      (initialize-schema)
      (initialize-schema username (jdbc/current-database)))
    (require-current-schema
     (trs "Database is not fully migrated and migration is disallowed."))))

(defn- require-db-connection-as [datasource migrator]
  (jdbc/with-db-connection datasource
