Relationships — ash v3.4.47 due to compilation constraints, we cannot guess the type of foreign keys based on the types of the destination attributes. It would cause potential compiler deadlocks. Instead, it just defaults to uuid, but you can change that default as shown in the section titled " Customizing default belongs_to attribute type" in the docs I linked.
defmodule Project.Domain.Foo do
use Ash.Resource,
domain: Project.Domain,
data_layer: AshPostgres.DataLayer
postgres do
table("foos")
repo(Project.Repo)
end
attributes do
integer_primary_key(:id)
attribute(:name, :string)
timestamps()
end
relationships do
belongs_to(:bar, Project.Domain.Bar)
end
end
defmodule Project.Domain.Bar do
use Ash.Resource,
domain: Project.Domain,
data_layer: AshPostgres.DataLayer
postgres do
table("bar")
repo(Project.Repo)
end
attributes do
integer_primary_key(:id)
attribute(:name, :string)
end
relationships do
has_many(:foo, Project.Domain.Foo)
end
end