diff --git a/src/puppetlabs/puppetdb/scf/migrate.clj b/src/puppetlabs/puppetdb/scf/migrate.clj index 74b7281b00..7f0a9dafcb 100644 --- a/src/puppetlabs/puppetdb/scf/migrate.clj +++ b/src/puppetlabs/puppetdb/scf/migrate.clj @@ -2617,16 +2617,17 @@ tables))] (if-not write-user (migrate) - (call-with-connections-blocked-during-migration - db-name - (distinct [read-user write-user]) - (fn [] - ;; So new tables, etc. are owned by the write-user - (jdbc/do-commands (str "set role " (jdbc/double-quote write-user))) - (try! - (migrate) - (finally - (jdbc/do-commands (str "set role " (jdbc/double-quote orig-user)))))))))) + (when-not (empty? (pending-migrations)) + (call-with-connections-blocked-during-migration + db-name + (distinct [read-user write-user]) + (fn [] + ;; So new tables, etc. are owned by the write-user + (jdbc/do-commands (str "set role " (jdbc/double-quote write-user))) + (try! + (migrate) + (finally + (jdbc/do-commands (str "set role " (jdbc/double-quote orig-user))))))))))) (defn initialize-schema "Ensures the database is migrated to the latest version, and returns