Fork me on GitHub
#datomic
<
2020-02-12
>
pfeodrippe13:02:24

Should the order matter at the installation of tuple attributes? This works

[{:db/ident :reg/course
  :db/valueType :db.type/ref
  :db/cardinality :db.cardinality/one}
 {:db/ident :reg/semester
  :db/valueType :db.type/ref
  :db/cardinality :db.cardinality/one}
 {:db/ident :reg/student
  :db/valueType :db.type/ref
  :db/cardinality :db.cardinality/one}
 {:db/ident :reg/semester+course+student
  :db/valueType :db.type/tuple
  :db/tupleAttrs [:reg/course :reg/semester :reg/student]
  :db/cardinality :db.cardinality/one
  :db/unique :db.unique/identity}]
While this doesn't
[{:db/ident :reg/semester+course+student
  :db/valueType :db.type/tuple
  :db/tupleAttrs [:reg/course :reg/semester :reg/student]
  :db/cardinality :db.cardinality/one
  :db/unique :db.unique/identity}
 {:db/ident :reg/course
  :db/valueType :db.type/ref
  :db/cardinality :db.cardinality/one}
 {:db/ident :reg/semester
  :db/valueType :db.type/ref
  :db/cardinality :db.cardinality/one}
 {:db/ident :reg/student
  :db/valueType :db.type/ref
  :db/cardinality :db.cardinality/one}]

marshall14:02:32

@pfeodrippe Yes, we are aware of that behavior, we are investigating whether it can be changed to be order insensitive

mynomoto18:02:30

Meanwhile a note in the docs would be helpful.

Ty14:02:21

Is datomic cloud the only way to use datomic?

ghadi14:02:00

no, there are two products: Cloud & On-Prem

ghadi14:02:54

if you go to http://datomic.com and click on Products or peruse some docs, you can see differences between the two

Ty14:02:30

Thanks! Much appreciated

Sam DeSota17:02:44

For non-breaking schema updates, is it fine to re-transact my entire apps schema idents every time I start an app instance? Could this cause any issues down the road?

ghadi18:02:34

1) don't do anything except non-breaking schema growth 2) yeah it's unnecessary and can probably cause issues, especially when you have many app instances

Sam DeSota18:02:36

Right, everything is non-breaking, I just put that qualifier in there for clarification. Didn't know if datomic only transacted changes anyway, I guess I'll have to write some sort of diffing engine, manually syncing the schema on each change doesn't work for my use case. Thank you.

ghadi18:02:17

dont need a diffing engine, just query

ghadi18:02:16

(set (map first (d/q '[:find ?name :where [?e :db/ident ?name] [?e :db/type]] db)))

ghadi18:02:26

then transact all the stuff that isn't in the set

ghadi18:02:52

(schema is not special, they're just ordinary entities)

Sam DeSota18:02:36

Got it, yeah I guess I only need to diff on the top level items, no need for a deeper tree diff update. Thanks again!

ghadi18:02:11

no problem... what does "top-level" mean?

ghadi18:02:20

you mean the existence of the attribute itself?

Sam DeSota18:02:56

I mean for example.. updating an existing entity from non-component entity to component entity, I can just re-transact the entire ident, instead of comparing all the individual db entity properties and updating only those that changed

ghadi18:02:16

yeah, understood. Another approach is to transact collections of schema and mark in the tx metadata something identifying the collection itself

ghadi18:02:38

that way one collection can make schema, then a later collection can update some part of it

ghadi18:02:38

that way instead of ensuring that attr :patient/id exists, you can ensure that 20200212-patient-stuff.edn is in the database

ghadi18:02:07

then you can add 2021-more-patient-stuff.edn later

ghadi18:02:31

we use an attribute called :migration/file to tag collections of schema in this way

Sam DeSota18:02:33

Got it, yeah using more traditional migration. I do like the first approach however, since all changes to Datomic are non-breaking anyway, I can use a declarative format agnostic to datomic for my schema, then generate the datomic idents, as well as schemas for other purposes ex: GraphQL from that source. It's been super helpful for rapidly building out internal apis without the need to duplicate schema information everywhere.

ghadi18:02:07

you can always query then transact only what's missing