Fork me on GitHub
souenzzo13:09:21 This doc string need a update it says "If the transaction times out, the call to transact itself will throw a RuntimeException" I got "clojure.lang.ExceptionInfo: :db.error/transaction-timeout Transaction timed out."

Alex Miller (Clojure team)13:09:42

ExceptionInfo is a RuntimeException


i remember once having to run d/administer-system as part of a Datomic Cloud upgrade, but i can't find any historical mention of it in the release notes. is that something we should be doing regularly when upgrading?


It’s only purpose right now is to upgrade schema on a db created with a version that predates the various features that introduced new schema. so you only run it once


these are on-prem docs, but the same applies


I can’t find equivalent cloud docs


so you should definitely not be running it regularly


Beginner here. To "update" an entity, must the entity have a :db.unique/identity attribute? Or is there a way to rely on the datomic assigned entity id for this?


It may help to think backwards. All transactions must eventually fully expand to a set of [:db/add e a v] or [:db/retract e a v] operations. Maps are a syntax sugar for :db/add s


the sugar is either 1) Your map has an explicit :db/id with an entity identifier (entity id, lookup-ref, or ident) 2) your map has a tempid, or 3) your map has no :db/id at all, so it gets a tempid automatically


later, after full expansion, some “e”s will be entity ids and some will still be tempids


if an e is a tempid and there’s an assertion that mentions a unique-identity attribute that already exists, the tempid can be substituted for the already-existing id


otherwise the tempid will be replaced with a newly-minted id


So I can use the entity id of an entity in :db/id to update that entity?


so, stepping back, you can do this {:db/id 1234 :foo "bar"} or {:db/id [:unique-attr "value"] :foo "bar"} or {:db/id :ident-value :foo "bar"} if you want to be explicit about what entity you want to assert on


this “upsertion” case should really be the less common case, and only matters if you want create-or-update behavior.


that said, you should still use a unique attribute of some kind (not necessarily unique-identity--unique-value is ok) to identify your entities rather than raw entity ids


Ok, so generally speaking, I should add UUID attributes to all entities in my schema, unless some other attribute will be unique. Correct?


all entities that need to be identifiable from outside datomic should have a unique attribute


sometimes you don’t need this. e.g. many isComponent entities have no meaning aside from their “parent” entity, and it’s often ok to not give these unique ids


the functions that construct txs that manipuate them will have a proper identifier for the parent and will find them that way


Ok, thanks very much for your help.

👍 6

glad to help, sorry if that was long-winded

Yuriy Zaytsev20:09:13

Hi there. I have a question about analytics. I want to have separate metaschemas for development and for production. What is the best way to do it? If I have for example 2 metaschemas in which order it will be applied?