Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Functional Programming
Diskuy-Backend
Commits
d622e014
Commit
d622e014
authored
Jan 26, 2021
by
Muhammad Rafif Elfazri
Browse files
add parent id for reply
parent
e2b19847
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/diskuy/forum/post.ex
View file @
d622e014
...
...
@@ -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
priv/repo/migrations/20201211055930_create_posts.exs
View file @
d622e014
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment