adding approach to fixing sql.
This commit is contained in:
18
scratch-sessions/fix-account-id.sql
Normal file
18
scratch-sessions/fix-account-id.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
|
||||
(defn original-base-id [{:keys [date bank-account-id description-original company-id amount]} index]
|
||||
(str (t/to-time-zone date (t/time-zone-for-offset -7)) "-" description-original "-" (double amount) "-" index "-" company-id))
|
||||
|
||||
(defn new-base-id [{:keys [date bank-account-id description-original company-id amount]} index]
|
||||
(str (t/to-time-zone date (t/time-zone-for-offset -7)) "-" bank-account-id "-" description-original "-" (double amount) "-" index "-" company-id))
|
||||
|
||||
(defn replacements []
|
||||
(loop [rows (get-graphql {:limit 100000})
|
||||
replacements []
|
||||
i 0]
|
||||
(let [result (->> rows
|
||||
(filter #(= (:id %) (sha-256 (original-base-id % i))))
|
||||
(map #(assoc % :new-id (sha-256 (new-base-id % i)))))]
|
||||
(if (= 10 i)
|
||||
(into replacements result)
|
||||
(recur rows (into replacements result ) (inc i))))))
|
||||
Reference in New Issue
Block a user