Skip to content

Instantly share code, notes, and snippets.

@shankardevy
Created July 8, 2017 03:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shankardevy/ac3e0e5523afe23ad297c5051a451741 to your computer and use it in GitHub Desktop.
Save shankardevy/ac3e0e5523afe23ad297c5051a451741 to your computer and use it in GitHub Desktop.
Customer schema module generated by Mix command.
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