-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a database schema to store the chat history
- Loading branch information
Marta Medio
committed
Mar 11, 2019
1 parent
816b881
commit 649e43e
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
defmodule Chat.Message do | ||
use Ecto.Schema | ||
import Ecto.Changeset | ||
|
||
|
||
schema "messages" do | ||
field :message, :string | ||
field :name, :string | ||
|
||
timestamps() | ||
end | ||
|
||
@doc false | ||
def changeset(message, attrs) do | ||
message | ||
|> cast(attrs, [:name, :message]) | ||
|> validate_required([:name, :message]) | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
defmodule Chat.Repo.Migrations.CreateMessages do | ||
use Ecto.Migration | ||
|
||
def change do | ||
create table(:messages) do | ||
add :name, :string | ||
add :message, :string | ||
|
||
timestamps() | ||
end | ||
|
||
end | ||
end |