Current section
Files
Jump to
Current section
Files
lib/ex_dav/storage/postgres/schemas/user.ex
defmodule ExDav.Storage.Postgres.Schemas.User do
@moduledoc "A DAV principal."
use Ecto.Schema
import Ecto.Changeset
alias ExDav.Storage.Postgres.Schemas.Collection
schema "caldav_users" do
field :username, :string
field :password, :string
field :display_name, :string
has_many :collections, Collection
timestamps(type: :utc_datetime)
end
def changeset(user, attrs) do
user
|> cast(attrs, [:username, :password, :display_name])
|> validate_required([:username, :password])
|> unique_constraint(:username)
end
end