From 3b5241a7f729752f28ed1edfb4b3ec9bb2a6f869 Mon Sep 17 00:00:00 2001
From: Arthur Ulfeldt <arthur@ulfeldt.com>
Date: Thu, 13 Apr 2017 14:42:44 -0700
Subject: [PATCH] fix db-pre-migration not running on postgres

---
 src/metabase/db.clj | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/metabase/db.clj b/src/metabase/db.clj
index aede803e3c9..bf20b1a09ff 100644
--- a/src/metabase/db.clj
+++ b/src/metabase/db.clj
@@ -212,11 +212,12 @@
 
    see https://github.com/metabase/metabase/issues/3715"
   [conn]
-  (let [fresh-install? (jdbc/with-db-metadata [meta (jdbc-details)] ;; don't migrate on fresh install
-                         (empty? (jdbc/metadata-query (.getTables meta nil nil "DATABASECHANGELOG" (into-array String ["TABLE"])))))
-        query (if (= (db-type) :h2)
-                "UPDATE DATABASECHANGELOG SET FILENAME = ?"
-                "UPDATE databasechangelog SET filename = ?")]
+  (let [liquibases-table-name (if (= (db-type) :h2)
+                                "DATABASECHANGELOG"
+                                "databasechangelog")
+        fresh-install? (jdbc/with-db-metadata [meta (jdbc-details)] ;; don't migrate on fresh install
+                         (empty? (jdbc/metadata-query (.getTables meta nil nil liquibases-table-name (into-array String ["TABLE"])))))
+        query (format "UPDATE %s SET FILENAME = ?" liquibases-table-name)]
     (when-not fresh-install?
       (jdbc/execute! conn [query "migrations/000_migrations.yaml"]))))
 
-- 
GitLab