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:
Martin Brennan
2022-05-23 10:07:15 +10:00
committed by GitHub
parent bf987af3ca
commit fcc2e7ebbf
63 changed files with 582 additions and 1833 deletions

View File

@ -281,10 +281,8 @@ after_initialize do
self.add_model_callback(Bookmark, :after_commit, on: :create) do
if self.user.enqueue_narrative_bot_job?
if SiteSetting.use_polymorphic_bookmarks && self.bookmarkable_type == "Post"
if self.bookmarkable_type == "Post"
Jobs.enqueue(:bot_input, user_id: self.user_id, post_id: self.bookmarkable_id, input: "bookmark")
elsif !SiteSetting.use_polymorphic_bookmarks && self.post.present?
Jobs.enqueue(:bot_input, user_id: self.user_id, post_id: self.post_id, input: "bookmark")
end
end
end