Skip to content

Commit

Permalink
Part 4: Create users schema
Browse files Browse the repository at this point in the history
  • Loading branch information
thebrianemory committed Jan 15, 2019
1 parent 058bc3f commit 0fa38b8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/catcasts/user.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
defmodule Catcasts.User do
use Ecto.Schema
import Ecto.Changeset


schema "users" do
field :email, :string
field :first_name, :string
field :last_name, :string
field :provider, :string
field :token, :string

timestamps()
end

@doc false
def changeset(user, attrs) do
user
|> cast(attrs, [:first_name, :last_name, :email, :provider, :token])
|> validate_required([:first_name, :last_name, :email, :provider, :token])
end
end
16 changes: 16 additions & 0 deletions priv/repo/migrations/20190115021601_create_users.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
defmodule Catcasts.Repo.Migrations.CreateUsers do
use Ecto.Migration

def change do
create table(:users) do
add :first_name, :string
add :last_name, :string
add :email, :string
add :provider, :string
add :token, :string

timestamps()
end

end
end

0 comments on commit 0fa38b8

Please sign in to comment.