|
| 1 | +(ns migrations.2026-05-14-fix-direction-of-interest-vms |
| 2 | + (:require [behave-cms.server :as cms] |
| 3 | + [behave-cms.store :refer [default-conn]] |
| 4 | + [datomic.api :as d] |
| 5 | + [schema-migrate.interface :as sm])) |
| 6 | + |
| 7 | +;; =========================================================================================================== |
| 8 | +;; Overview |
| 9 | +;; =========================================================================================================== |
| 10 | + |
| 11 | +;; Linking Group Variable Direciton of Interest to the variable direction interest |
| 12 | + |
| 13 | +;; =========================================================================================================== |
| 14 | +;; Initialize |
| 15 | +;; =========================================================================================================== |
| 16 | + |
| 17 | +(cms/init-db!) |
| 18 | + |
| 19 | +#_{:clj-kondo/ignore [:missing-docstring]} |
| 20 | +(def conn (default-conn)) |
| 21 | + |
| 22 | +;; =========================================================================================================== |
| 23 | +;; Payload |
| 24 | +;; =========================================================================================================== |
| 25 | + |
| 26 | +#_{:clj-kondo/ignore [:missing-docstring]} |
| 27 | +(def direction-of-interest-eid |
| 28 | + (sm/t-key->eid conn "behaveplus:surface:input:directions_of_surface_spread__wind:surface_fire_wind__spread:direction-of-interest:direction-of-interest")) |
| 29 | + |
| 30 | +#_{:clj-kondo/ignore [:missing-docstring]} |
| 31 | +(def direction-of-interest-variable-eid |
| 32 | + (sm/name->eid conn :variable/name "Direction of Interest")) |
| 33 | + |
| 34 | +#_{:clj-kondo/ignore [:missing-docstring]} |
| 35 | +(def payload [{:db/id direction-of-interest-variable-eid |
| 36 | + :variable/group-variables [direction-of-interest-eid]}]) |
| 37 | + |
| 38 | +;; =========================================================================================================== |
| 39 | +;; Transact Payload |
| 40 | +;; =========================================================================================================== |
| 41 | + |
| 42 | +(comment |
| 43 | + #_{:clj-kondo/ignore [:missing-docstring]} |
| 44 | + (try (def tx-data @(d/transact conn payload)) |
| 45 | + (catch Exception e (str "caught exception: " (.getMessage e))))) |
| 46 | + |
| 47 | +;; =========================================================================================================== |
| 48 | +;; In case we need to rollback. |
| 49 | +;; =========================================================================================================== |
| 50 | + |
| 51 | +(comment |
| 52 | + (sm/rollback-tx! conn tx-data)) |
0 commit comments