Use git hash to enable automated help import#48
Use git hash to enable automated help import#48rjsheperd wants to merge 2 commits intorj-update-help-04-05-2025from
Conversation
|
The update to using the git hash to store in a migration entity looks good. One thing I noticed however in already committed code help_import.cljln 97: Has (defn rollback-import
"Rollback imports. Option to provide a transaction date."
[& args]
(cms/init-db!)
(let [a-datetime (first args)
conn @ds/datomic-conn
db (d/db conn)
-now (now)
tx-remove-id (q-tx db (format "help-import-remove-%s" (or a-datetime -now)))
tx-add-id (q-tx db (format "help-import-add-%s" (or a-datetime -now)))]
(sm/rollback-tx! conn tx-remove-id)
(sm/rollback-tx! conn tx-add-id))) |
|
Thanks for catching this, Kenny. I've gone ahead and updated the Regarding this comment:
The transaction ID from the Datom is stored as the fourth element, ( This has made me think that we could wrap the |
|
I'm not seeing where the transaction is being stored in the migration datom. Looking at ln 86-94 block: (when-not existing-tx?
#_(println (format "Removing old help docs from hash: %s" -now))
(d/transact conn (concat [(sm/->migration remove-tx)]
(remove-existing-pages-tx db en-us)))
#_(println (format "Adding new help docs %s" -now))
(d/transact conn (concat [(sm/->migration add-tx)]
(cleaned-topics-tx behave-docs en-us)
(cleaned-variables-tx behave-docs en-us))))The transaction from What I think we'd need is something like this. (let [tx1 @(d/transact conn (remove-existing-pages-tx db en-us))
tx2 @(d/transact conn (concat (cleaned-topics-tx behave-docs en-us)
(cleaned-variables-tx behave-docs en-us)))
tx-id1 (nth (first (:tx-data tx1)) 3)
tx-id2 (nth (first (:tx-data tx2)) 3)]
(d/transact conn (sm/->migration {:id remove-tx ;NOTE sm/->migration and the schema would need to be updated accordingly
:txs [tx-id1 tx-id2]}))) |
|
Regarding the multi transaction migration. Take a look at This migration needed to move a set of group variables from one group to another. I had to break this up into two separate transactions:
I had to do this because group-variables in the schema is group-variables are components in groups. Deleting an entity will delete it's components too. I guess we have this to facilitate {:db/ident :group/group-variables
:db/doc "Group's group variables."
:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many
:db/isComponent true} |
|
Good point. I wonder if we can do something where each sub-migration must be named separately? Maybe we can use a Ideally we want to get to a place where each migration namespace (or sub-migration) provides the migration identifier, and can be easily identified. |
|
Could the migration identifier be the namespace of the migration script? |
|
Totally. I had a script that I had written for this. Let me add that to this. |
Purpose
EOM