Skip to content

Commit

Permalink
Added script for 7.0.x DB migration
Browse files Browse the repository at this point in the history
  • Loading branch information
mluypaert committed Jan 12, 2024
1 parent e3d7d0e commit 80cc3e2
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions resources/updates/7.0.x-datomic-DB-updates.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
(require '[datomic.api :as d])

;;Change uri as appropriate on deploying to different environments
(def uri "datomic:ddb-local://localhost:8000/WBNames_local/wormbase")
(def conn (d/connect uri))
(def db (d/db conn))

;; Drop all currently stored auth-tokens (invalidated by new code, so no longer usable)
(d/transact conn (map (fn [entity] [:db/retract (first entity) :person/auth-token (second entity)]) (d/q '[:find ?e ?authtoken :where [?e :person/email ?email] [?e :person/name ?name] [?e :person/auth-token ?authtoken]] db)))

;; Install new attributes for auth-token and account usage tracking
(def new-attributes [#:db{:ident :person/auth-token-stored-at,
:valueType :db.type/instant,
:cardinality :db.cardinality/one,
:doc "When the current auth-token was stored."}
#:db{:ident :person/auth-token-last-used,
:valueType :db.type/instant,
:cardinality :db.cardinality/one,
:doc "When the stored auth-token was last used to access the API."}
#:db{:ident :person/last-activity,
:valueType :db.type/instant,
:cardinality :db.cardinality/one,
:doc "When the user last showed any activity in the NS (through either API or web)."}])

(d/transact conn new-attributes)

0 comments on commit 80cc3e2

Please sign in to comment.