Fakultas Ilmu Komputer UI

Commit d622e014 authored by Muhammad Rafif Elfazri's avatar Muhammad Rafif Elfazri
Browse files

add parent id for reply

parent e2b19847
......@@ -7,13 +7,14 @@ defmodule Diskuy.Forum.Post do
field :points, :integer
field :thread_id, :id
field :user_id, :id
field :parent_id, :id
timestamps()
end
@doc false
def changeset(post, attrs) do
post
|> cast(attrs, [:message, :points, :thread_id, :user_id])
|> cast(attrs, [:message, :points, :thread_id, :user_id, :parent_id])
|> validate_required([:message, :points, :thread_id, :user_id])
end
end
......@@ -7,6 +7,7 @@ defmodule Diskuy.Repo.Migrations.CreatePosts do
add :points, :integer
add :thread_id, references(:threads, on_delete: :delete_all, type: :id)
add :user_id, references(:users, on_delete: :delete_all, type: :id)
add :parent_id, references(:posts, on_delete: :delete_all, type: :id)
timestamps()
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment