[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:
parent
cebce7da42
commit
97af827bc2
13
lib/wabanex/user.ex
Normal file
13
lib/wabanex/user.ex
Normal 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
|
15
priv/repo/migrations/20210622015725_create_users_table.exs
Normal file
15
priv/repo/migrations/20210622015725_create_users_table.exs
Normal 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
|
Loading…
x
Reference in New Issue
Block a user