Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
0e9ebbfb
Unverified
Commit
0e9ebbfb
authored
6 years ago
by
Cam Saul
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #9725 from metabase/load-from-h2-should-work-without-file-prefix
Add file: prefix if needed when running load-from-h2
parents
683a72fc
cd9284e4
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/cmd/load_from_h2.clj
+9
-2
9 additions, 2 deletions
src/metabase/cmd/load_from_h2.clj
test/metabase/cmd/load_from_h2_test.clj
+18
-2
18 additions, 2 deletions
test/metabase/cmd/load_from_h2_test.clj
with
27 additions
and
4 deletions
src/metabase/cmd/load_from_h2.clj
+
9
−
2
View file @
0e9ebbfb
...
...
@@ -14,7 +14,10 @@
mysql -u root -e 'DROP DATABASE IF EXISTS metabase; CREATE DATABASE metabase;'
MB_DB_TYPE=mysql MB_DB_HOST=localhost MB_DB_PORT=3305 MB_DB_USER=root MB_DB_DBNAME=metabase lein run load-from-h2
```"
(
:require
[
clojure.java.jdbc
:as
jdbc
]
(
:require
[
clojure.java
[
io
:as
io
]
[
jdbc
:as
jdbc
]]
[
clojure.string
:as
str
]
[
colorize.core
:as
color
]
[
medley.core
:as
m
]
[
metabase
...
...
@@ -97,9 +100,13 @@
;; above this line)
DataMigrations
])
(
defn-
add-file-prefix-if-needed
[
connection-string-or-filename
]
(
if
(
str/starts-with?
connection-string-or-filename
"file:"
)
connection-string-or-filename
(
str
"file:"
(
.getAbsolutePath
(
io/file
connection-string-or-filename
)))))
(
defn-
h2-details
[
h2-connection-string-or-nil
]
(
let
[
h2-filename
(
or
h2-connection-string-or-nil
@
metabase.db/db-file
)]
(
let
[
h2-filename
(
add-file-prefix-if-needed
(
or
h2-connection-string-or-nil
@
metabase.db/db-file
)
)
]
(
mdb/jdbc-details
{
:type
:h2,
:db
(
str
h2-filename
";IFEXISTS=TRUE"
)})))
...
...
This diff is collapsed.
Click to expand it.
test/metabase/cmd/load_from_h2_test.clj
+
18
−
2
View file @
0e9ebbfb
(
ns
metabase.cmd.load-from-h2-test
(
:require
[
expectations
:refer
:all
]
metabase.cmd.load-from-h2
(
:require
[
expectations
:refer
[
expect
]
]
[
metabase.cmd.load-from-h2
:as
load-from-h2
]
[
metabase.util
:as
u
]
[
toucan.models
:as
models
]))
;; Make sure load-from-h2 works with or without `file:` prefix
(
expect
{
:classname
"org.h2.Driver"
:subprotocol
"h2"
:subname
"file:/path/to/metabase.db;IFEXISTS=TRUE"
:type
:h2
}
(
#
'load-from-h2/h2-details
"/path/to/metabase.db"
))
(
expect
{
:classname
"org.h2.Driver"
:subprotocol
"h2"
:subname
"file:/path/to/metabase.db;IFEXISTS=TRUE"
:type
:h2
}
(
#
'load-from-h2/h2-details
"file:/path/to/metabase.db"
))
;; Check to make sure we're migrating all of our entities.
;; This fetches the `metabase.cmd.load-from-h2/entities` and compares it all existing entities
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment