feat: add chat schema and migration

This commit is contained in:
João Paulo Dubas 2024-10-09 00:12:39 +00:00
parent 7766585e07
commit efd8914d74
Signed by: joao.dubas
SSH Key Fingerprint: SHA256:V1mixgOGRc/YMhGx/DNkOSmJxgA2vHNrDZEk3wt/kOA
2 changed files with 30 additions and 0 deletions

18
lib/slax/chat/room.ex Normal file
View File

@ -0,0 +1,18 @@
defmodule Slax.Chat.Room do
use Ecto.Schema
import Ecto.Changeset
schema "rooms" do
field :name, :string
field :topic, :string
timestamps(type: :utc_datetime)
end
@doc false
def changeset(room, attrs) do
room
|> cast(attrs, [:name, :topic])
|> validate_required([:name, :topic])
end
end

View File

@ -0,0 +1,12 @@
defmodule Slax.Repo.Migrations.CreateRooms do
use Ecto.Migration
def change do
create table(:rooms) do
add :name, :string, null: false
add :topic, :text
timestamps(type: :utc_datetime)
end
end
end