Fork me on GitHub

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 [email protected], :db-after [email protected], :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


@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 "In order to add :db/unique, you must first have an AVET index including that attribute."


that seems more in line with the error message


good catch!


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


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?


@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


I just saw that today. I’ve been using 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.


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