mirror of
https://github.com/mgerb/classic-wow-forums
synced 2026-01-09 00:42:47 +00:00
server - add hidden fields to thread/reply
This commit is contained in:
@@ -12,6 +12,7 @@ defmodule MyApp.Data.Reply do
|
||||
field :content, :string
|
||||
field :edited, :boolean, default: false
|
||||
field :quote_id, :integer
|
||||
field :hidden, :boolean, default: false
|
||||
has_one :user, Data.User, foreign_key: :id, references: :user_id
|
||||
timestamps(type: :utc_datetime)
|
||||
end
|
||||
@@ -54,7 +55,7 @@ defmodule MyApp.Data.Reply do
|
||||
end
|
||||
end
|
||||
|
||||
@spec user_update(map) :: {:ok, map} | {:error, map}
|
||||
@spec user_update(map) :: {:ok, String.t} | {:error, String.t}
|
||||
def user_update(params) do
|
||||
id = Map.get(params, "id")
|
||||
user_id = Map.get(params, "user_id")
|
||||
|
||||
@@ -16,6 +16,7 @@ defmodule MyApp.Data.Thread do
|
||||
field :locked, :boolean, default: false
|
||||
field :edited, :boolean, default: false
|
||||
field :reply_count, :integer, default: 0
|
||||
field :hidden, :boolean, default: false
|
||||
has_many :replies, Data.Reply
|
||||
has_one :user, Data.User, foreign_key: :id, references: :user_id
|
||||
has_one :last_reply, Data.User, foreign_key: :id, references: :last_reply_id
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
defmodule MyApp.Repo.Migrations.ReplyAddHiddenField do
|
||||
use Ecto.Migration
|
||||
import Ecto.Query
|
||||
|
||||
def up do
|
||||
alter table(:reply) do
|
||||
add :hidden, :boolean
|
||||
end
|
||||
|
||||
flush()
|
||||
|
||||
from(r in "reply",
|
||||
update: [set: [hidden: false]])
|
||||
|> MyApp.Repo.update_all([])
|
||||
end
|
||||
|
||||
def down do
|
||||
alter table(:reply) do
|
||||
remove :hidden
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,22 @@
|
||||
defmodule MyApp.Repo.Migrations.ThreadAddHiddenField do
|
||||
use Ecto.Migration
|
||||
import Ecto.Query
|
||||
|
||||
def up do
|
||||
alter table(:thread) do
|
||||
add :hidden, :boolean
|
||||
end
|
||||
|
||||
flush()
|
||||
|
||||
from(r in "thread",
|
||||
update: [set: [hidden: false]])
|
||||
|> MyApp.Repo.update_all([])
|
||||
end
|
||||
|
||||
def down do
|
||||
alter table(:thread) do
|
||||
remove :hidden
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user