mirror of
https://github.com/discourse/discourse.git
synced 2026-08-11 21:45:25 -05:00
FEATURE: Promote polymorphic bookmarks to default and migrate (#16729)
This commit migrates all bookmarks to be polymorphic (using the bookmarkable_id and bookmarkable_type) columns. It also deletes all the old code guarded behind the use_polymorphic_bookmarks setting and changes that setting to true for all sites and by default for the sake of plugins. No data is deleted in the migrations, the old post_id and for_topic columns for bookmarks will be dropped later on.
This commit is contained in:
@@ -608,10 +608,9 @@ class TopicsController < ApplicationController
|
||||
|
||||
def bookmark
|
||||
topic = Topic.find(params[:topic_id].to_i)
|
||||
first_post = topic.ordered_posts.first
|
||||
|
||||
bookmark_manager = BookmarkManager.new(current_user)
|
||||
bookmark_manager.create(post_id: first_post.id)
|
||||
bookmark_manager.create_for(bookmarkable_id: topic.id, bookmarkable_type: "Topic")
|
||||
|
||||
if bookmark_manager.errors.any?
|
||||
return render_json_error(bookmark_manager, status: 400)
|
||||
|
||||
Reference in New Issue
Block a user