From 8f9b827d15cc50647b4adbf5fb10d171ad1fe616 Mon Sep 17 00:00:00 2001 From: Kelv Date: Wed, 23 Oct 2024 13:42:35 +0800 Subject: [PATCH] DEV: drop password-related columns from users table (#29187) --- app/models/user.rb | 7 +++---- ...0241011080517_drop_password_columns_from_users.rb | 12 ++++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 db/post_migrate/20241011080517_drop_password_columns_from_users.rb diff --git a/app/models/user.rb b/app/models/user.rb index 00b9af0ed3a..07a4ca5b267 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,10 +2,9 @@ class User < ActiveRecord::Base self.ignored_columns = [ - :old_seen_notification_id, # TODO: Remove when column is dropped. At this point, the migration to drop the column has not been written. - :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. + :salt, # TODO: Remove when DropPasswordColumnsFromUsers has been promoted to pre-deploy. + :password_hash, # TODO: Remove when DropPasswordColumnsFromUsers has been promoted to pre-deploy. + :password_algorithm, # TODO: Remove when DropPasswordColumnsFromUsers has been promoted to pre-deploy. :old_seen_notification_id, # TODO: Remove once 20240829140226_drop_old_notification_id_columns has been promoted to pre-deploy ] diff --git a/db/post_migrate/20241011080517_drop_password_columns_from_users.rb b/db/post_migrate/20241011080517_drop_password_columns_from_users.rb new file mode 100644 index 00000000000..e43c98aad1d --- /dev/null +++ b/db/post_migrate/20241011080517_drop_password_columns_from_users.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true +class DropPasswordColumnsFromUsers < ActiveRecord::Migration[7.1] + DROPPED_COLUMNS ||= { users: %i[password_hash salt password_algorithm] } + + def up + DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) } + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end