Skip to content
Snippets Groups Projects
Unverified Commit 73bc209a authored by Cam Saul's avatar Cam Saul
Browse files

Add `lein run refresh-integration-test-db-metadata` cmd & update metadata

parent 60e2ba37
No related branches found
No related tags found
No related merge requests found
......@@ -52,4 +52,5 @@ bin/release/aws-eb/metabase-aws-eb.zip
coverage-summary.json
.DS_Store
bin/node_modules/
*.log
\ No newline at end of file
*.log
*.trace.db
No preview for this file type
......@@ -40,7 +40,7 @@
[]
;; override env var that would normally make Jetty block forever
(require 'environ.core)
(intern 'environ.core 'env (assoc environ.core/env :mb-jetty-join "false"))
(intern 'environ.core 'env (assoc @(resolve 'environ.core/env) :mb-jetty-join "false"))
(u/profile "start-normally" ((resolve 'metabase.core/start-normally))))
(defn ^:command reset-password
......@@ -49,6 +49,12 @@
(require 'metabase.cmd.reset-password)
((resolve 'metabase.cmd.reset-password/reset-password!) email-address))
(defn ^:command refresh-integration-test-db-metadata
"Re-sync the frontend integration test DB's metadata for the Sample Dataset."
[]
(require 'metabase.cmd.refresh-integration-test-db-metadata)
((resolve 'metabase.cmd.refresh-integration-test-db-metadata/refresh-integration-test-db-metadata)))
(defn ^:command help
"Show this help message listing valid Metabase commands."
[]
......
(ns metabase.cmd.refresh-integration-test-db-metadata
(:require [clojure.java.io :as io]
[environ.core :refer [env]]
[metabase
[db :as mdb]
[util :as u]]
[metabase.models
[database :refer [Database]]
[field :refer [Field]]
[table :refer [Table]]]
[metabase.sample-data :as sample-data]
[metabase.sync :as sync]
[toucan.db :as db]))
(defn- test-fixture-db-path
"Get the path to the test fixture DB that we'll use for `MB_DB_FILE`. Throw an Exception if the file doesn't exist."
[]
(let [path (str (System/getProperty "user.dir") "/frontend/test/__runner__/test_db_fixture.db")]
(when-not (or (.exists (io/file (str path ".h2.db")))
(.exists (io/file (str path ".mv.db"))))
(throw (Exception. (str "Could not find frontend integration test DB at path: " path ".h2.db (or .mv.db)"))))
path))
(defn ^:command refresh-integration-test-db-metadata
"Re-sync the frontend integration test DB's metadata for the Sample Dataset."
[]
(let [db-path (test-fixture-db-path)]
;; now set the path at MB_DB_FILE
(intern 'environ.core 'env (assoc env :mb-db-type "h2", :mb-db-file db-path))
;; set up the DB, make sure sample dataset is added
(mdb/setup-db!)
(sample-data/add-sample-dataset!)
(sample-data/update-sample-dataset-if-needed!)
;; clear out all Fingerprints so we force analysis to run again. Clear out special type and has_field_values as
;; well so we can be sure those will be set to the correct values
(db/debug-print-queries
(db/update! Field {:set {:fingerprint_version 0, :special_type nil, :has_field_values nil}}))
;; now re-run sync
(sync/sync-database! (Database :is_sample true))
;; done!
(println "Finished.")))
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