-
-
Save shankardevy/ac3e0e5523afe23ad297c5051a451741 to your computer and use it in GitHub Desktop.
Customer schema module generated by Mix command.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Mango.CRM.Customer do | |
use Ecto.Schema | |
import Ecto.Changeset | |
alias Mango.CRM.Customer | |
schema "customers" do | |
field :email, :string | |
field :name, :string | |
field :password_hash, :string | |
field :phone, :string | |
field :residence_area, :string | |
timestamps() | |
end | |
@doc false | |
def changeset(%Customer{} = customer, attrs) do | |
customer | |
|> cast(attrs, [:name, :email, :phone, :residence_area, :password_hash]) | |
|> validate_required([:name, :email, :phone, :residence_area, :password_hash]) | |
|> unique_constraint(:email) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment