A platform for community discussion. Free, open, simple.
DEV: Re-add polymorphic bookmark columns (#16245)
Martin Brennan2f1ddadff7dd
diff --git a/app/models/bookmark.rb b/app/models/bookmark.rbindex e2f413bf13b..35363b60d7e 100644--- a/app/models/bookmark.rb+++ b/app/models/bookmark.rb@@ -4,8 +4,6 @@ class Bookmark < ActiveRecord::Base# these columns were here for a very short amount of time,# hence the very short ignore timeself.ignored_columns = [- "bookmarkable_id", # TODO 2022-04-01 remove- "bookmarkable_type", # TODO 2022-04-01 remove"topic_id", # TODO 2022-04-01: remove"reminder_type" # TODO 2021-04-01: remove]@@ -181,9 +179,12 @@ end# auto_delete_preference :integer default(0), not null# pinned :boolean default(FALSE)# for_topic :boolean default(FALSE), not null+# bookmarkable_id :integer+# bookmarkable_type :string## Indexes#+# idx_bookmarks_user_polymorphic_unique (user_id,bookmarkable_type,bookmarkable_id) UNIQUE# index_bookmarks_on_post_id (post_id)# index_bookmarks_on_reminder_at (reminder_at)# index_bookmarks_on_reminder_set_at (reminder_set_at)diff --git a/db/migrate/20220322024216_add_bookmark_polymorphic_columns_again.rb b/db/migrate/20220322024216_add_bookmark_polymorphic_columns_again.rbnew file mode 100644index 00000000000..0f4727f41e6--- /dev/null+++ b/db/migrate/20220322024216_add_bookmark_polymorphic_columns_again.rb@@ -0,0 +1,10 @@+# frozen_string_literal: true++class AddBookmarkPolymorphicColumnsAgain < ActiveRecord::Migration[6.1]+ def change+ add_column :bookmarks, :bookmarkable_id, :integer+ add_column :bookmarks, :bookmarkable_type, :string++ add_index :bookmarks, [:user_id, :bookmarkable_type, :bookmarkable_id], name: "idx_bookmarks_user_polymorphic_unique", unique: true+ end+end