fix: use resource's primary key config

This commit is contained in:
Zach Daniel 2020-04-30 20:16:58 -04:00
parent b7ca80d2eb
commit 8cbad05f4a
No known key found for this signature in database
GPG key ID: C377365383138D4B

View file

@ -9,14 +9,13 @@ defmodule Ash.Schema do
defmacro define_schema(name) do defmacro define_schema(name) do
quote do quote do
use Ecto.Schema use Ecto.Schema
@primary_key {:id, :binary_id, autogenerate: true} @primary_key false
@foreign_key_type :binary_id
schema unquote(name) do schema unquote(name) do
for attribute <- @attributes do for attribute <- @attributes do
unless attribute.name == :id do field(attribute.name, Ash.Type.ecto_type(attribute.type),
field(attribute.name, Ash.Type.ecto_type(attribute.type)) primary_key: attribute.primary_key?
end )
end end
for relationship <- Enum.filter(@relationships, &(&1.type == :belongs_to)) do for relationship <- Enum.filter(@relationships, &(&1.type == :belongs_to)) do