Created
January 30, 2020 22:20
-
-
Save eraserhd/2697af2eab84f7366fcc2c6c4bdc06bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns twou.centralpark.server.database.migrations | |
(:require | |
[meander.epsilon :as m] | |
[medley.core :as medley] | |
[twou.centralpark.edn :as edn])) | |
(defn program-of-study-primary-brand [eav-map] | |
(reduce #(%2 %1) | |
eav-map | |
(m/search eav-map | |
{?pos {:program-of-study/uuid (m/some ?uuid) | |
:program-of-study/primary-brand ((m/some ?pb))} | |
?pb {:brand/programs-of-study ?b-pos}} | |
(if (nil? ?b-pos) | |
#(assoc-in % [?pb :brand/programs-of-study] (list ?pos)) | |
#(update-in % [?pb :brand/programs-of-study] (fn [val] (->> val (cons ?pos) sort distinct))))))) | |
(defn- landing-page-cdn-taskexec? [exec-uuid] | |
(= (.getMostSignificantBits exec-uuid) | |
(.getMostSignificantBits #uuid "411305e5-639e-43a1-bc8f-65cce1373e9c"))) | |
(defn remove-pos-from-landing-page-cdn-inputs [eav-map] | |
(reduce #(%2 %1) | |
eav-map | |
(m/search eav-map | |
{?lsti {:last-sent-task-input/exec-uuid ((m/pred landing-page-cdn-taskexec?)) | |
:last-sent-task-input/input ((m/app edn/read-string ?input))}} | |
(fn [eav-map] | |
(let [new-input (edn/pprint-str | |
(medley/dissoc-in ?input [:centralpark.taskexec/program | |
:centralpark.program/programs-of-study]))] | |
(assoc-in eav-map [?lsti :last-sent-task-input/input] (list new-input))))))) | |
(def pre-schema | |
"These are applied before the schema is migrated, and is useful for | |
renaming attributes before the schema is applied." | |
[]) | |
(def post-schema | |
"These are applied after the schema is migrated. Most migrations should be | |
here." | |
[#'program-of-study-primary-brand | |
#'remove-pos-from-landing-page-cdn-inputs]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment