A platform for community discussion. Free, open, simple.
DEV: Re-add polymorphic bookmark columns (#16261)
Martin Brennan8040b95e8c4a
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/20220107011124_drop_bookmark_polymorphic_trigger.rb b/db/migrate/20220107011124_drop_bookmark_polymorphic_trigger.rbdeleted file mode 100644index daacc978cac..00000000000--- a/db/migrate/20220107011124_drop_bookmark_polymorphic_trigger.rb+++ /dev/null@@ -1,11 +0,0 @@-# frozen_string_literal: true--class DropBookmarkPolymorphicTrigger < ActiveRecord::Migration[6.1]- def up- DB.exec("DROP FUNCTION IF EXISTS sync_bookmarks_polymorphic_column_data CASCADE")- end-- def down- raise ActiveRecord::IrreversibleMigration- end-enddiff --git a/db/migrate/20220104053343_add_bookmark_polymorphic_columns.rb b/db/migrate/20220322024216_add_bookmark_polymorphic_columns.rbsimilarity index 100%rename from db/migrate/20220104053343_add_bookmark_polymorphic_columns.rbrename to db/migrate/20220322024216_add_bookmark_polymorphic_columns.rbdiff --git a/db/post_migrate/20220107014925_drop_bookmark_polymorphic_columns.rb b/db/post_migrate/20220107014925_drop_bookmark_polymorphic_columns.rbdeleted file mode 100644index 0fbe6cb7625..00000000000--- a/db/post_migrate/20220107014925_drop_bookmark_polymorphic_columns.rb+++ /dev/null@@ -1,17 +0,0 @@-# frozen_string_literal: true--class DropBookmarkPolymorphicColumns < ActiveRecord::Migration[6.1]- DROPPED_COLUMNS ||= {- bookmarks: %i{bookmarkable_id bookmarkable_type}- }-- def up- DROPPED_COLUMNS.each do |table, columns|- Migration::ColumnDropper.execute_drop(table, columns)- end- end-- def down- raise ActiveRecord::IrreversibleMigration- end-end