KLIM22I6ITB6YKW77VOCKA2PKCCNNBTAEZA5QEOQKYZK4YANPZ4QC
defmodule Cake.Accounts.User do
use Ecto.Schema
import Ecto.Changeset
schema "users" do
field :email, :string
field :id, Ecto.UUID
field :user_name, :string
field :role, :id
timestamps()
end
@doc false
def changeset(user, attrs) do
user
|> cast(attrs, [:id, :user_name, :email])
|> validate_required([:id, :user_name, :email])
end
end
defmodule Cake.Accounts.Role do
use Ecto.Schema
import Ecto.Changeset
schema "roles" do
field :name, :string
timestamps()
end
@doc false
def changeset(role, attrs) do
role
|> cast(attrs, [:name])
|> validate_required([:name])
end
end