Fork me on GitHub
#datomic
<
2020-09-10
>
davewo18:09:08

I am trying to update schema to add uniqueness to an attribute like so:

[{:db/id        :owsy/dot-number
  :db/unique    :db.unique/identity}]
but I get the following error:
clojure.lang.ExceptionInfo: java.lang.IllegalArgumentException: :db.error/invalid-alter-attribute Error: {:db/error :db.error/unique-without-index, :attribute :owsy/dot-number} {:succeeded [{:norm-name :V20200901/clearfork-last-funded-date-SNAPSHOT, :tx-index 0, :tx-result {:db-before datomic.db.Db@ad33f60, :db-after datomic.db.Db@d3dfdde3, :tx-data [#datom[13194140022304 50 #inst "2020-09-10T18:17:17.664-00:00" 13194140022304 true] #datom[13194140022304 72 :V20200901/clearfork-last-funded-date-SNAPSHOT 13194140022304 true] #datom[13194140022304 73 0 13194140022304 true] #datom[456 44 true 13194140022304 true] #datom[0 19 456 13194140022304 true]], :tempids {-9223354444669732589 13194140022304}}}], :failed {:norm-name :V20200901/clearfork-last-funded-date-SNAPSHOT, :tx-index 1, :reason "java.lang.IllegalArgumentException: :db.error/invalid-alter-attribute Error: {:db/error :db.error/unique-without-index, :attribute :owsy/dot-number}"}}
This is confusing because I thought that adding :db/unique would also set :db/index true

ghadi18:09:42

@davewo I think it's saying that your data isn't already unique :db.error/unique-without-index so you can't add a uniqueness constraint

davewo18:09:41

https://docs.datomic.com/on-prem/schema.html#schema-alteration "In order to add :db/unique, you must first have an AVET index including that attribute."

davewo18:09:51

that seems more in line with the error message

ghadi18:09:54

good catch!

davewo18:09:28

and because those indexes are added asynch, adding the :db/index in the same tx doesn't work (which I tried)

colinkahn21:09:53

Is there anyway to clone an in memory peer connection? Lets say I want to transact a large schema and then be able to make clones of it at that point for testing purposes and not incur the schema transaction cost each time?

colinkahn22:09:37

@U083D6HK9 cool, I’ve run across this lib a couple times but I guess it never sunk in what usecase it solved 😄

Joe Lane22:09:29

@colinkahn Have you considered using the new dev-local database? Copying a database is literally cp my-db the-copy-of-my-db

colinkahn22:09:27

I just saw that today. I’ve been using https://github.com/ComputeSoftware/datomic-client-memdb for testing, but they’re saying to switch over to dev-local. But at first glance seems like it writes to disk which I don’t need for tests.

val_waeselynck00:09:39

Whait, copying Datomic dbs is no longer O(1) ? What a pity :)