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
a018a098
Commit
a018a098
authored
8 years ago
by
Cam Saül
Browse files
Options
Downloads
Patches
Plain Diff
Code cleanup
parent
63f3b390
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/metabase/sync_database/sync.clj
+9
-9
9 additions, 9 deletions
src/metabase/sync_database/sync.clj
with
9 additions
and
9 deletions
src/metabase/sync_database/sync.clj
+
9
−
9
View file @
a018a098
...
...
@@ -118,14 +118,14 @@
"Update the working `Table` and `Field` metadata for a given `Table` based on the latest raw schema information.
This function uses the data in `RawTable` and `RawColumn` to update the working data models as needed."
[{
raw-table-id
:raw_table_id,
table-id
:id,
:as
existing-table
}]
(
when-let
[{
database-id
:database_id,
:as
raw-tbl
}
(
db/sel
:one
RawTable
:id
raw-table-id
)]
(
when-let
[{
database-id
:database_id,
:as
raw-t
a
bl
e
}
(
db/sel
:one
RawTable
:id
raw-table-id
)]
(
try
(
if-not
(
:active
raw-tbl
)
(
if-not
(
:active
raw-t
a
bl
e
)
;; looks like the table has been deactivated, so lets retire this Table and its fields
(
table/retire-tables
#
{
table-id
})
;; otherwise update based on the RawTable/RawColumn information
(
do
(
save-table-fields!
(
table/update-table
existing-table
raw-tbl
))
(
save-table-fields!
(
table/update-table
existing-table
raw-t
a
bl
e
))
;; handle setting any fk relationships
(
when-let
[
table-fks
(
k/select
RawColumn
...
...
@@ -174,13 +174,13 @@
(
defn-
create-and-update-tables!
"Create/update tables (and their fields)."
[
database
existing-tables
raw-tables
]
(
doseq
[{
raw-table-id
:id,
:as
raw-tbl
}
(
non-blacklisted-tables
raw-tables
)]
(
doseq
[{
raw-table-id
:id,
:as
raw-t
a
bl
e
}
(
non-blacklisted-tables
raw-tables
)]
(
try
(
if-let
[
existing-table
(
get
existing-tables
raw-table-id
)]
;; table already exists, update it
(
save-table-fields!
(
table/update-table
existing-table
raw-tbl
)
)
;; must be a new table, insert it
(
save-table-fields!
(
table/create-table
(
:id
database
)
(
assoc
raw-tbl
:raw-table-id
raw-table-id
))))
(
save-table-fields!
(
if-let
[
existing-table
(
get
existing-tables
raw-table-id
)]
;; table already exists, update it
(
table/update-table
existing-table
raw-t
a
bl
e
)
;; must be a new table, insert it
(
table/create-table
(
:id
database
)
(
assoc
raw-t
a
bl
e
:raw-table-id
raw-table-id
))))
(
catch
Throwable
e
(
log/error
(
u/format-color
'red
"Unexpected error syncing table"
)
e
)))))
...
...
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