33 lines
880 B
Elixir
33 lines
880 B
Elixir
defmodule Odinsea.Database.Schema.BbsThread do
|
|
@moduledoc """
|
|
Ecto schema for the bbs_threads table.
|
|
Represents guild BBS threads.
|
|
"""
|
|
|
|
use Ecto.Schema
|
|
import Ecto.Changeset
|
|
|
|
@primary_key {:threadid, :id, autogenerate: true}
|
|
|
|
schema "bbs_threads" do
|
|
field :postercid, :integer
|
|
field :name, :string, default: ""
|
|
field :timestamp, :integer
|
|
field :icon, :integer
|
|
field :startpost, :string
|
|
field :guildid, :integer
|
|
field :localthreadid, :integer
|
|
|
|
has_many :bbs_replies, Odinsea.Database.Schema.BbsReply, foreign_key: :threadid
|
|
end
|
|
|
|
@doc """
|
|
Changeset for creating a BBS thread.
|
|
"""
|
|
def creation_changeset(bbs_thread, attrs) do
|
|
bbs_thread
|
|
|> cast(attrs, [:postercid, :name, :timestamp, :icon, :startpost, :guildid, :localthreadid])
|
|
|> validate_required([:postercid, :timestamp, :guildid, :localthreadid])
|
|
end
|
|
end
|