mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Drop old bookmark columns (#15405)
As per 22208836c5
these are no longer needed, a follow up commit will remove the ignored
columns.
This commit is contained in:
parent
20fe5eceb8
commit
b22450c7a8
@ -20,20 +20,6 @@ class Bookmark < ActiveRecord::Base
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO (martin) (2021-12-01) Remove this once plugins are not using it.
|
|
||||||
def self.reminder_types
|
|
||||||
@reminder_types ||= Enum.new(
|
|
||||||
later_today: 1,
|
|
||||||
next_business_day: 2,
|
|
||||||
tomorrow: 3,
|
|
||||||
next_week: 4,
|
|
||||||
next_month: 5,
|
|
||||||
custom: 6,
|
|
||||||
start_of_next_business_week: 7,
|
|
||||||
later_this_week: 8
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
validate :unique_per_post_for_user,
|
validate :unique_per_post_for_user,
|
||||||
on: [:create, :update],
|
on: [:create, :update],
|
||||||
if: Proc.new { |b| b.will_save_change_to_post_id? || b.will_save_change_to_user_id? }
|
if: Proc.new { |b| b.will_save_change_to_post_id? || b.will_save_change_to_user_id? }
|
||||||
@ -196,7 +182,6 @@ end
|
|||||||
# index_bookmarks_on_post_id (post_id)
|
# index_bookmarks_on_post_id (post_id)
|
||||||
# index_bookmarks_on_reminder_at (reminder_at)
|
# index_bookmarks_on_reminder_at (reminder_at)
|
||||||
# index_bookmarks_on_reminder_set_at (reminder_set_at)
|
# index_bookmarks_on_reminder_set_at (reminder_set_at)
|
||||||
# index_bookmarks_on_topic_id (topic_id)
|
|
||||||
# index_bookmarks_on_user_id (user_id)
|
# index_bookmarks_on_user_id (user_id)
|
||||||
# index_bookmarks_on_user_id_and_post_id_and_for_topic (user_id,post_id,for_topic) UNIQUE
|
# index_bookmarks_on_user_id_and_post_id_and_for_topic (user_id,post_id,for_topic) UNIQUE
|
||||||
#
|
#
|
||||||
|
22
db/post_migrate/20211224010204_drop_old_bookmark_columns.rb
Normal file
22
db/post_migrate/20211224010204_drop_old_bookmark_columns.rb
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'migration/column_dropper'
|
||||||
|
|
||||||
|
class DropOldBookmarkColumns < ActiveRecord::Migration[6.1]
|
||||||
|
DROPPED_COLUMNS ||= {
|
||||||
|
bookmarks: %i{
|
||||||
|
topic_id
|
||||||
|
reminder_type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def up
|
||||||
|
DROPPED_COLUMNS.each do |table, columns|
|
||||||
|
Migration::ColumnDropper.execute_drop(table, columns)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
raise ActiveRecord::IrreversibleMigration
|
||||||
|
end
|
||||||
|
end
|
@ -33,11 +33,9 @@ class BookmarkManager
|
|||||||
# See Bookmark.auto_delete_preferences,
|
# See Bookmark.auto_delete_preferences,
|
||||||
# this is used to determine when to delete a bookmark
|
# this is used to determine when to delete a bookmark
|
||||||
# automatically.
|
# automatically.
|
||||||
# TODO (martin) (2021-12-01) Remove reminder_type keyword argument once plugins are not using it.
|
|
||||||
def create(
|
def create(
|
||||||
post_id:,
|
post_id:,
|
||||||
name: nil,
|
name: nil,
|
||||||
reminder_type: nil,
|
|
||||||
reminder_at: nil,
|
reminder_at: nil,
|
||||||
for_topic: false,
|
for_topic: false,
|
||||||
options: {}
|
options: {}
|
||||||
@ -100,8 +98,7 @@ class BookmarkManager
|
|||||||
BookmarkReminderNotificationHandler.send_notification(bookmark)
|
BookmarkReminderNotificationHandler.send_notification(bookmark)
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO (martin) (2021-12-01) Remove reminder_type keyword argument once plugins are not using it.
|
def update(bookmark_id:, name:, reminder_at:, options: {})
|
||||||
def update(bookmark_id:, name:, reminder_at:, reminder_type: nil, options: {})
|
|
||||||
bookmark = find_bookmark_and_check_access(bookmark_id)
|
bookmark = find_bookmark_and_check_access(bookmark_id)
|
||||||
|
|
||||||
success = bookmark.update(
|
success = bookmark.update(
|
||||||
|
Loading…
Reference in New Issue
Block a user