[day-02] add user schema and migration

Add elixir struct to represent an user and its corresponding
representation on the database.
This commit is contained in:
Joao P Dubas 2021-06-22 23:55:02 +00:00
parent cebce7da42
commit 97af827bc2
2 changed files with 28 additions and 0 deletions

13
lib/wabanex/user.ex Normal file
View File

@ -0,0 +1,13 @@
defmodule Wabanex.User do
use Ecto.Schema
@primary_key {:id, :binary_id, autogenerate: true}
schema "users" do
field :name, :string
field :email, :string
field :password, :string
timestamps()
end
end

View File

@ -0,0 +1,15 @@
defmodule Wabanex.Repo.Migrations.CreateUsersTable do
use Ecto.Migration
def change do
create table(:users) do
add :email, :string
add :name, :string
add :password, :string
timestamps()
end
create unique_index(:users, [:email])
end
end