port over some more
This commit is contained in:
32
lib/odinsea/database/schema/bbs_thread.ex
Normal file
32
lib/odinsea/database/schema/bbs_thread.ex
Normal file
@@ -0,0 +1,32 @@
|
||||
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
|
||||
Reference in New Issue
Block a user