Hi Mike,
Thanks for your report! After reviewing the behavior, I don't believe this is a regression, but rather an existing bug **in the mem protocol** that has been present for some time. The core issue is that an attribute must already have an AVET index before it can be made unique, as outlined in our documentation:
Schema Change - Changing :db/unique (
https://docs.datomic.com/schema/schema-change.html#changing-db-unique)
>In Datomic Pro, Datomic must already be maintaining an AVET index on the attribute.
The fact that you were able to add :db/unique to an attribute without an AVET index in the mem protocol is indeed a bug, and we will be addressing it in an upcoming release.
A few key takeaways:
- I created a gist using your code snippet that demonstrates this behavior across different versions. (
https://gist.github.com/Jaretbinford/c3640e3bdf7606aa9eb54bd1b0608f7b)
- The behavior was consistent for mem but correctly enforced in dev and all durable storages.
- In the upcoming release, the correct behavior will be to reject the transaction that attempts to make an attribute unique without first maintaining an index, rather than allowing that transaction.
I would be very interested if you have ever seen this not throw in any durable storage (posgres, sql, dev, cass etc)? To my testing it is not possible in those storages. As you will see in the aforementioned gist at the bottom, this should be the correct behavior in `mem`:
```
;@(d/transact conn [{:db/id :admin/id,
; :db/unique :db.unique/identity}
; {:db/id "admin"
; :db/ident :admin/bug
; :admin/id admin-id}])
;Execution error (Exceptions$IllegalArgumentExceptionInfo) at datomic.error/arg (error.clj:79).
;:db.error/invalid-alter-attribute Error: {:db/error :db.error/unique-without-index, :attribute :admin/id}
```
Let me know if you have any further questions! I will circle back here once we have released a fix.