Fork me on GitHub
#datomic
<
2024-02-06
>
itaied14:02:09

Hey all, I've accidentally transacted a schema with a typo in valueType (string instead of a ref). I know that a type of an attribute cannot be modified, but I was wondering if I can restore the schema somehow, or I have to change the name of the attribute?

favila16:02:29

You can either restore a backup from before you made the attribute, or you can rename the attribute

favila16:02:23

:something/my-attr -> :DO-NOT-USE/my-attr for example. If you want even more safety, you can install an attribute predicate that always throws--that makes it impossible to assert anything with that attribute

itaied17:02:44

Backup and restore is not an option since production data has been inserted already (but not to this attribute). Something bothers me with :DO_NOT_USE, I don't like "garbage" in my db... Why isn't it possible to delete an attribute without values?

favila17:02:05

It’s not possible to retract attributes, that’s all

favila17:02:49

I can’t speak for datomic team, but I imagine it’s two reasons: 1) the cases where retraction would be safe are vanishingly small (i.e. never asserted the attribute as an attribute in a datom ever), so it’s not worth the engineering effort for a probably tricky implementation. 2) Datomic is philosophically opposed to deleting mistakes: https://blog.datomic.com/2014/08/stuff-happens-fixing-bad-data-in-datomic.html

favila17:02:39

The analogy I’ve heard is: you wouldn’t rebase your git repo to remove a bug (erasing the record of the bug being introduced), you add a new commit to fix it.

itaied17:02:09

Thank you for your replies, I appreciate it. I believe it is related to the datomic team decision to make stuff simpler. Regarding the git analogy, I see it more like once you touched a file, you cannot change its type (extension).