diff --git a/lein_tasks/leiningen/migration_summary.clj b/lein_tasks/leiningen/migration_summary.clj new file mode 100644 index 0000000000000000000000000000000000000000..84b2d1e7fe64364ead1ac3de2c293edd0885109c --- /dev/null +++ b/lein_tasks/leiningen/migration_summary.clj @@ -0,0 +1,21 @@ +(ns leiningen.migration-summary + (:require [leiningen.core.eval :as lein])) + +(defn migration-summary [project & args] + (lein/eval-in-project + project + `(do + (require '[metabase.config :as ~'config] + '[metabase.db :as ~'db] + '[metabase.driver.generic-sql.sync :as ~'sync]) + (let [db# {:engine (name (config/config-kw :mb-db-type)) + :details {:conn_str (db/metabase-db-conn-str)}}] + (->> (sync/table-names db#) + (map (fn [table-name#] + (println (format "\n* %s" table-name#)) + (->> (sync/jdbc-columns db# table-name#) + (sort-by :column_name) + (map (fn [{:keys [~'type_name ~'column_name]}] + (println (format " * %s %s" ~'column_name ~'type_name)))) + dorun))) + dorun))))) diff --git a/src/metabase/db.clj b/src/metabase/db.clj index 476868b2d2c13604372c7516c9d27e00ad447f06..62a2d250ef75568f6b2e7bf1a34e7d34de62efbb 100644 --- a/src/metabase/db.clj +++ b/src/metabase/db.clj @@ -55,6 +55,15 @@ :password (config/config-str :mb-db-pass) :host (config/config-str :mb-db-host)}))) +(defn metabase-db-conn-str [] + (case (config/config-kw :mb-db-type) + :h2 (db-file) + :postgres (format "host=%s port=%d dbname=%s user=%s password=%s" + (config/config-str :mb-db-host) + (config/config-int :mb-db-port) + (config/config-str :mb-db-dbname) + (config/config-str :mb-db-user) + (config/config-str :mb-db-pass)))) (defn test-db-conn "Simple test of a JDBC connection."