i've created a set of attributes in the Datomic schema. Their :db/idents are grouped into three namespaces: :name, :tree, :node. Now i want to delete all of these and start fresh. I've found all of the required attributes:
(def results
(q '[:find ?e
:where [?e :db/ident ?v]
[(namespace ?v) ?res]
[(contains? #{"task", "node", "tree"} ?res)]
]
(db conn)))
Then created a set of retractEntity statements:
(def retract-statements
(into [] (map #(vector :db.fn/retractEntity (first %1)) results)))
And now i'm trying to invoke the transaction:
@(d/transact conn [retract-statements])
It gives me: :db.error/invalid-attribute Schema change must be followed by :db.install/attribute or :db.alter/attribute
Apparently i'm doing something wrong. Can someone please help?
Thanks!
There is no way to directly retract attributes in Datomic. Once you install an attribute, it's around forever unless you delete the entire database. This makes sense, given that Datomic (except in the special case of excision) never truly deletes any data - if you could actually remove attributes, then data originally transacted against those attributes would not be retrievable.
Note that you can rename attributes, but that it still keeps its old ident as a synonym as well unless you repurpose it for something else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With