-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate old pre-1.37 "Custom Drill-through" settings to x.37+ "Click Behavior" #15014
Projects
Milestone
Comments
flamber
changed the title
Migrate old < x.37.x "click behavior" viz settings to > x.37.x "custom drill-thru"
Migrate old < x.37.x "Custom Drill-through" viz settings to > x.37.x "Click Behavior"
Mar 2, 2021
dpsutton
added a commit
that referenced
this issue
Mar 3, 2021
flamber
changed the title
Migrate old < x.37.x "Custom Drill-through" viz settings to > x.37.x "Click Behavior"
Migrate old pre-1.37 "Custom Drill-through" settings to x.37+ "Click Behavior"
Mar 5, 2021
dpsutton
added a commit
that referenced
this issue
Mar 10, 2021
* Fix click through behavior (#15014) * formatting * Safer get's, author metadata and correct added * Don't return anything if we didn't modify it * Make private and add a docstring * Generate json strings rather than long in-line versions * Docstrings and prevent migrating ones that may already be migrated * Noisier as it now merges click_behavior on top of existing * update docstring with new nesting * always keep column settings previously the script was only looking for column settings which included view_as or link_template. Now we always keep those columns and merge in the new click_behavior when those keys are present * linkTemplateText -> linkTextTemplate * Ensure dashcard goes on top of card viz settings * Update expected now that dash merges on top of card * drop columns that don't have view_as so we don't overwrite the top level stuff if there is already a click_behavior. That signifies that either this migration has run, or perhaps already has had manual intervention. An open question is if we extend this to the columns: if there's manual intervention do we really want to be mucking about in here? Also, go back to the dropping columns style. ```clojure (if (and ...) (assoc m col (merge field-settings click-behavior)) m) ;; here we omit the column again in our reduce-kv ``` * Fundamentally: scour card for click and merge them into dashcard reshape all click behaviors in both and merge them in. Still some broken tests at the moment * Remove old style click behavior no longer expected * fixed * Some more comments and remove some silly select keys and when-lets just compute both keys and then u/select-non-nil-keys and be done with it * Docstrinc additions about nil * Remove niles, test scenario #5 from flamber * Handle empties and nil _AFTER_ merging previously had taken care to punt things down to nil, collapse empty maps, etc. but this is a value that will merge on top of a map rather than with the map ```clojure (m/deep-merge {:a {:b :c}} {:a nil}) {:a nil} ;; vs (m/deep-merge {:a {:b :c}} {:a {}}) {:a {:b :c}} ``` so let the postwalk after the merge clean up empty collections and nil values and let them blend as normal * Deep merge and prioritize new shape in card and dashcard ```clojure (m/deep-merge fixed-card fixed-dashcard (existing-fixed card) (existing-fixed dashcard)) ``` This is the change here essentially. Fix the card and dashcard, look for existing new shapes on the card and dashcard as well * Don't merge existing fix from card. can't happen this change though did help out. we want to resolve when there are old style and new style on the same dashcard. In this case, the new style should persist: ```clojure (testing "If there is migration eligible on dash but also new style on dash, new style wins" (let [dash {"column_settings" {"[\"ref\",[\"field-id\",4]]" {"view_as" "link" "link_template" "http://old" ;; this stuff could be migrated "link_text" "old" "column_title" "column title" "click_behavior" {"type" "link", "linkType" "url", ;; but there is already a new style and it wins "linkTemplate" "http://new", "linkTextTemplate" "new"}}}}] (is (= {"column_settings" {"[\"ref\",[\"field-id\",4]]" {"click_behavior" {"type" "link", "linkType" "url", "linkTemplate" "http://new", "linkTextTemplate" "new"}, "column_title" "column title"}}} (migrate nil dash))))) ``` note the column settings for field-id 4 have the old style and the new style but the result is that the new style survives. This happens from the `(m/deep-merge fixed-card fixed-dashcard (existing-fixed dashcard))` as the existing is put on top * Don't strip original values * propagate old info in migration test
rlotun
moved this from Key Bug fixes (target: 38.2)
to Closed Issues and PRs
in 39 and 38.x Planning Board
Mar 11, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We need to update
Card
andDashboardCard
visualization_settings
and convert them from the old format to the new format where appropriate. @flamber has written SQL to do this for Postgres specifically:To get this working for MySQL & H2 as well we can leverage the data migrations code we have in
metabase.db.data-migrations
. An example data migration for viz settings would look something like@flamber or @paulrosenzweig might be able to help out with questions around how the format has changed between old and new versions
The text was updated successfully, but these errors were encountered: