mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 08:49:06 +08:00
DEV: Drop old notification id columns (#28550)
The `id` column of `notifications` table and `notification_id` columns
of the other tables have been migrated to bigint in previous commits
(for example, 799a45a
).
In order to run the migrations with zero downtime, the data had to be
copied to new columns and swapped, but the old columns have been kept
to allow for rollback. They are no longer needed now.
This commit is contained in:
parent
29ac39cf41
commit
8016fcab33
|
@ -2,7 +2,7 @@
|
|||
|
||||
class Notification < ActiveRecord::Base
|
||||
self.ignored_columns = [
|
||||
:old_id, # TODO: Remove when column is dropped. At this point, the migration to drop the column has not been writted.
|
||||
:old_id, # TODO: Remove once 20240829140226_drop_old_notification_id_columns has been promoted to pre-deploy
|
||||
]
|
||||
|
||||
attr_accessor :acting_user
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class ShelvedNotification < ActiveRecord::Base
|
||||
self.ignored_columns = [
|
||||
:old_notification_id, # TODO: Remove when column is dropped. At this point, the migration to drop the column has not been writted.
|
||||
:old_notification_id, # TODO: Remove once 20240829140226_drop_old_notification_id_columns has been promoted to pre-deploy
|
||||
]
|
||||
|
||||
belongs_to :notification
|
||||
|
|
|
@ -6,6 +6,7 @@ class User < ActiveRecord::Base
|
|||
:salt, # TODO: Remove when column is dropped. At this point, the migration to drop the column has not been written.
|
||||
:password_hash, # TODO: Remove when column is dropped. At this point, the migration to drop the column has not been written.
|
||||
:password_algorithm, # TODO: Remove when column is dropped. At this point, the migration to drop the column has not been written.
|
||||
:old_seen_notification_id, # TODO: Remove once 20240829140226_drop_old_notification_id_columns has been promoted to pre-deploy
|
||||
]
|
||||
|
||||
include Searchable
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class UserBadge < ActiveRecord::Base
|
||||
self.ignored_columns = [
|
||||
:old_notification_id, # TODO: Remove when column is dropped. At this point, the migration to drop the column has not been writted.
|
||||
:old_notification_id, # TODO: Remove once 20240829140226_drop_old_notification_id_columns has been promoted to pre-deploy
|
||||
]
|
||||
|
||||
belongs_to :badge
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DropOldNotificationIdColumns < ActiveRecord::Migration[7.1]
|
||||
DROPPED_COLUMNS = {
|
||||
notifications: %i[old_id],
|
||||
shelved_notifications: %i[old_notification_id],
|
||||
users: %i[old_seen_notification_id],
|
||||
user_badges: %i[old_notification_id],
|
||||
}
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
module Chat
|
||||
class MentionNotification < ActiveRecord::Base
|
||||
self.table_name = "chat_mention_notifications"
|
||||
|
||||
self.ignored_columns = [
|
||||
:old_notification_id, # TODO remove once this column is removed. Migration to drop the column has not been written.
|
||||
:old_notification_id, # TODO: Remove once 20240829140227_drop_chat_mention_notifications_old_id_column has been promoted to pre-deploy
|
||||
]
|
||||
|
||||
self.table_name = "chat_mention_notifications"
|
||||
|
||||
belongs_to :chat_mention, class_name: "Chat::Mention"
|
||||
belongs_to :notification, dependent: :destroy
|
||||
end
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DropChatMentionNotificationsOldIdColumn < ActiveRecord::Migration[7.1]
|
||||
DROPPED_COLUMNS = { chat_mention_notifications: %i[old_notification_id] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user