feat: add chat schema and migration
This commit is contained in:
parent
7766585e07
commit
efd8914d74
18
lib/slax/chat/room.ex
Normal file
18
lib/slax/chat/room.ex
Normal 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
|
12
priv/repo/migrations/20241008234613_create_rooms.exs
Normal file
12
priv/repo/migrations/20241008234613_create_rooms.exs
Normal 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
|
Loading…
x
Reference in New Issue
Block a user