Skip to content
Snippets Groups Projects
Commit c654098d authored by Tom Robinson's avatar Tom Robinson
Browse files

Merge branch 'master' of github.com:metabase/metabase into issue-9396

parents adbd6c68 a7c44355
No related branches found
No related tags found
No related merge requests found
(defproject metabase/lein-include-drivers "1.0.4"
(defproject metabase/lein-include-drivers "1.0.5"
:min-lein-version "2.5.0"
:eval-in-leiningen true
:deploy-repositories [["clojars" {:sign-releases false}]])
(ns leiningen.include-drivers
(:require [clojure.string :as str]
[leiningen.core.project :as p])
(import java.io.File))
(:import java.io.File))
(defn- file-exists? [^String filename]
(.exists (File. filename)))
......
......@@ -112,7 +112,7 @@
[org.eclipse.jetty/jetty-server "9.4.14.v20181114"] ; We require JDK 8 which allows us to run Jetty 9.4, ring-jetty-adapter runs on 1.7 which forces an older version
[ring/ring-json "0.4.0"] ; Ring middleware for reading/writing JSON automatically
[stencil "0.5.0"] ; Mustache templates for Clojure
[toucan "1.11.0-SNAPSHOT" :exclusions [org.clojure/java.jdbc honeysql]]] ; Model layer, hydration, and DB utilities
[toucan "1.11.0" :exclusions [org.clojure/java.jdbc honeysql]]] ; Model layer, hydration, and DB utilities
:main ^:skip-aot metabase.core
......@@ -154,10 +154,7 @@
[lein-bikeshed "0.4.1"] ; Linting
[lein-check-namespace-decls "1.0.1"] ; lints namespace declarations
[lein-environ "1.1.0"] ; easy access to environment variables
[lein-expectations "0.0.8"] ; run unit tests with 'lein expectations'
;; TODO - should this be moved to the new RING profile?
[lein-ring "0.12.3" ; start the HTTP server with 'lein ring server'
:exclusions [org.clojure/clojure]]]
[lein-expectations "0.0.8"]] ; run unit tests with 'lein expectations'
:env {:mb-run-mode "dev"}
:jvm-opts ["-Dlogfile.path=target/log"]
......@@ -183,11 +180,13 @@
[:exclude-tests {}]
:ring
[:exclude-tests {}]
[:exclude-tests
{:dependencies
[[lein-ring "0.12.5" :exclusions [org.clojure/clojure]]]}] ; start the HTTP server with 'lein ring server'
:with-include-drivers-middleware
{:plugins
[[metabase/lein-include-drivers "1.0.4"]]
[[metabase/lein-include-drivers "1.0.5"]]
:middleware
[leiningen.include-drivers/middleware]}
......
......@@ -30,21 +30,22 @@
(def db-file
"Path to our H2 DB file from env var or app config."
;; see http://h2database.com/html/features.html for explanation of options
(delay (if (config/config-bool :mb-db-in-memory)
;; In-memory (i.e. test) DB
"mem:metabase;DB_CLOSE_DELAY=-1"
;; File-based DB
(let [db-file-name (config/config-str :mb-db-file)
db-file (io/file db-file-name)
;; we need to enable MVCC for Quartz JDBC backend to work! Quartz depends on row-level locking, which
;; means without MVCC we "will experience dead-locks". MVCC is the default for everyone using the
;; MVStore engine anyway so this only affects people still with legacy PageStore databases
options ";DB_CLOSE_DELAY=-1;MVCC=TRUE;"]
(apply str "file:" (if (.isAbsolute db-file)
;; when an absolute path is given for the db file then don't mess with it
[db-file-name options]
;; if we don't have an absolute path then make sure we start from "user.dir"
[(System/getProperty "user.dir") "/" db-file-name options]))))))
(delay
(if (config/config-bool :mb-db-in-memory)
;; In-memory (i.e. test) DB
"mem:metabase;DB_CLOSE_DELAY=-1"
;; File-based DB
(let [db-file-name (config/config-str :mb-db-file)
;; we need to enable MVCC for Quartz JDBC backend to work! Quartz depends on row-level locking, which
;; means without MVCC we "will experience dead-locks". MVCC is the default for everyone using the
;; MVStore engine anyway so this only affects people still with legacy PageStore databases
;;
;; Tell H2 to defrag when Metabase is shut down -- can reduce DB size by multiple GIGABYTES -- see #6510
options ";DB_CLOSE_DELAY=-1;MVCC=TRUE;DEFRAG_ALWAYS=TRUE"]
;; H2 wants file path to always be absolute
(str "file:"
(.getAbsolutePath (io/file db-file-name))
options)))))
(def ^:private jdbc-connection-regex
#"^(jdbc:)?([^:/@]+)://(?:([^:/@]+)(?::([^:@]+))?@)?([^:@]+)(?::(\d+))?/([^/?]+)(?:\?(.*))?$")
......@@ -88,25 +89,34 @@
(or (:type @connection-string-details)
(config/config-kw :mb-db-type)))
(def db-connection-details
(def ^:private db-connection-details
"Connection details that can be used when pretending the Metabase DB is itself a `Database` (e.g., to use the Generic
SQL driver functions on the Metabase DB itself)."
(delay (or @connection-string-details
(case (db-type)
:h2 {:type :h2 ; TODO - we probably don't need to specifc `:type` here since we can just call (db-type)
:db @db-file}
:mysql {:type :mysql
:host (config/config-str :mb-db-host)
:port (config/config-int :mb-db-port)
:dbname (config/config-str :mb-db-dbname)
:user (config/config-str :mb-db-user)
:password (config/config-str :mb-db-pass)}
:postgres {:type :postgres
:host (config/config-str :mb-db-host)
:port (config/config-int :mb-db-port)
:dbname (config/config-str :mb-db-dbname)
:user (config/config-str :mb-db-user)
:password (config/config-str :mb-db-pass)}))))
(delay
(when (= (db-type) :h2)
(log/warn
(u/format-color 'red
(str
(trs "WARNING: Using Metabase with an H2 application database is not recomended for production deployments.")
(trs "For production deployments, we highly recommend using Postgres, MySQL, or MariaDB instead.")
(trs "If you decide to continue to use H2, please be sure to back up the database file regularly.")
(trs "See https://metabase.com/docs/latest/operations-guide/start.html#migrating-from-using-the-h2-database-to-mysql-or-postgres for more information.")))))
(or @connection-string-details
(case (db-type)
:h2 {:type :h2 ; TODO - we probably don't need to specifc `:type` here since we can just call (db-type)
:db @db-file}
:mysql {:type :mysql
:host (config/config-str :mb-db-host)
:port (config/config-int :mb-db-port)
:dbname (config/config-str :mb-db-dbname)
:user (config/config-str :mb-db-user)
:password (config/config-str :mb-db-pass)}
:postgres {:type :postgres
:host (config/config-str :mb-db-host)
:port (config/config-int :mb-db-port)
:dbname (config/config-str :mb-db-dbname)
:user (config/config-str :mb-db-user)
:password (config/config-str :mb-db-pass)}))))
(defn jdbc-details
"Takes our own MB details map and formats them properly for connection details for JDBC."
......
......@@ -10,14 +10,11 @@
[metabase.util :as u]
[metabase.util.i18n :refer [trs]]
[yaml.core :as yaml])
(:import java.io.File
[java.nio.file Files Path]))
(:import [java.nio.file Files Path]))
(defn- plugins-dir-filename ^String []
(or (env/env :mb-plugins-dir)
(str (System/getProperty "user.dir")
File/separator
"plugins")))
(.getAbsolutePath (io/file "plugins"))))
;; logic for determining plugins dir -- see below
(defonce ^:private plugins-dir*
......
(ns metabase.sync.analyze.fingerprint.insights-test
(:require [expectations :refer :all]
[metabase.sync.analyze.fingerprint.insights :refer :all :as i]))
[metabase.sync.analyze.fingerprint.insights :as i :refer :all]))
(def ^:private cols [{:base_type :type/DateTime} {:base_type :type/Number}])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment