Skip to content

A platform for community discussion. Free, open, simple.

DEV: Drop old notification id columns (#28550)

Bianca Nenciu8016fcab332a
diff --git a/app/models/notification.rb b/app/models/notification.rb
index 42768c594da..356691b8ff7 100644
--- a/app/models/notification.rb
+++ b/app/models/notification.rb
@@ -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
diff --git a/app/models/shelved_notification.rb b/app/models/shelved_notification.rb
index 57eba4b3978..633872f3d65 100644
--- a/app/models/shelved_notification.rb
+++ b/app/models/shelved_notification.rb
@@ -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
diff --git a/app/models/user.rb b/app/models/user.rb
index 661dd9cf6bb..00e71a234d7 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -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
diff --git a/app/models/user_badge.rb b/app/models/user_badge.rb
index 5f4bfb889e2..b75160363d0 100644
--- a/app/models/user_badge.rb
+++ b/app/models/user_badge.rb
@@ -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
diff --git a/db/post_migrate/20240829140226_drop_old_notification_id_columns.rb b/db/post_migrate/20240829140226_drop_old_notification_id_columns.rb
new file mode 100644
index 00000000000..6e4b4f7a08b
--- /dev/null
+++ b/db/post_migrate/20240829140226_drop_old_notification_id_columns.rb
@@ -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
diff --git a/plugins/chat/app/models/chat/mention_notification.rb b/plugins/chat/app/models/chat/mention_notification.rb
index 31a5bb8f2e8..577ccc075fb 100644
--- a/plugins/chat/app/models/chat/mention_notification.rb
+++ b/plugins/chat/app/models/chat/mention_notification.rb
@@ -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
diff --git a/plugins/chat/db/post_migrate/20240829140227_drop_chat_mention_notifications_old_id_column.rb b/plugins/chat/db/post_migrate/20240829140227_drop_chat_mention_notifications_old_id_column.rb
new file mode 100644
index 00000000000..d643ff99223
--- /dev/null
+++ b/plugins/chat/db/post_migrate/20240829140227_drop_chat_mention_notifications_old_id_column.rb
@@ -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