Closed
Description
Describe the bug
If i create resource with
multitenancy do
strategy :attribute
attribute :organization_id
end
and have another resource relating to this one, generated migration is wrong.
Fails with error:
** (Postgrex.Error) ERROR 42830 (invalid_foreign_key) there is no unique constraint matching given keys for referenced table "<table_name>"
To fix i need to add
identities do
identity :unique_id, [:id]
end
which creates unique index with tenant (organization_id in this case prefix) so unique index [:organization_id, :id]
Then migrations works fine
Expected behavior
It would add corrcet unique indexes by default for primary fields with multitenancy
Runtime
- Elixir version - Elixir 1.14.3 (compiled with Erlang/OTP 25)
- Erlang version - Erlang/OTP 25
- OS - macos 13.1
- Ash version - 2.9.4