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
3eca231b
Commit
3eca231b
authored
8 years ago
by
Cam Saül
Browse files
Options
Downloads
Patches
Plain Diff
Check whether Metabase DB is set up before attempting to set site-url in middleware
parent
e44f4b9e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/db.clj
+7
-2
7 additions, 2 deletions
src/metabase/db.clj
src/metabase/middleware.clj
+5
-4
5 additions, 4 deletions
src/metabase/middleware.clj
with
12 additions
and
6 deletions
src/metabase/db.clj
+
7
−
2
View file @
3eca231b
...
...
@@ -289,6 +289,11 @@
(
def
^
:private
setup-db-has-been-called?
(
atom
false
))
(
defn
db-is-setup?
"True if the Metabase DB is setup and ready."
^
Boolean
[]
@
setup-db-has-been-called?
)
(
def
^
:dynamic
*allow-potentailly-unsafe-connections*
"We want to make *every* database connection made by the drivers safe -- read-only, only connect if DB file exists, etc.
At the same time, we'd like to be able to use driver functionality like `can-connect-with-details?` to check whether we can
...
...
@@ -360,11 +365,11 @@
[
&
{
:keys
[
db-details
auto-migrate
]
:or
{
db-details
@
db-connection-details
auto-migrate
true
}}]
(
reset!
setup-db-has-been-called?
true
)
(
verify-db-connection
db-details
)
(
run-schema-migrations!
auto-migrate
db-details
)
(
create-connection-pool!
(
jdbc-details
db-details
))
(
run-data-migrations!
))
(
run-data-migrations!
)
(
reset!
setup-db-has-been-called?
true
))
(
defn
setup-db-if-needed!
"Call `setup-db!` if DB is not already setup; otherwise this does nothing."
...
...
This diff is collapsed.
Click to expand it.
src/metabase/middleware.clj
+
5
−
4
View file @
3eca231b
...
...
@@ -260,10 +260,11 @@
"Middleware to set the `site-url` Setting if it's unset the first time a request is made."
[
handler
]
(
fn
[{{
:strs
[
origin
host
]
:as
headers
}
:headers,
:as
request
}]
(
when-not
(
public-settings/site-url
)
(
when-let
[
site-url
(
or
origin
host
)]
(
log/info
"Setting Metabase site URL to"
site-url
)
(
public-settings/site-url
site-url
)))
(
when
(
mdb/db-is-setup?
)
(
when-not
(
public-settings/site-url
)
(
when-let
[
site-url
(
or
origin
host
)]
(
log/info
"Setting Metabase site URL to"
site-url
)
(
public-settings/site-url
site-url
))))
(
handler
request
)))
...
...
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