change migration to mark password columns in users table as readonly

This commit is contained in:
Kelvin Tan 2024-09-13 16:03:00 +08:00
parent 3cd2563208
commit 6f1c0c8fea
No known key found for this signature in database
GPG Key ID: 49C85DCE965C53EF
1 changed files with 4 additions and 4 deletions

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
class DropPasswordColumnsFromUsers < ActiveRecord::Migration[7.1]
DROPPED_COLUMNS ||= { users: %i[password_hash salt password_algorithm] }
class MakePasswordColumnsFromUsersReadOnly < ActiveRecord::Migration[7.1]
def up
# remove invalid triggers/functions dependent on the columns to be dropped
execute <<~SQL.squish
@ -11,7 +9,9 @@ class DropPasswordColumnsFromUsers < ActiveRecord::Migration[7.1]
DROP FUNCTION IF EXISTS mirror_user_password_data;
SQL
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
%i[password_hash salt password_algorithm].each do |column|
Migration::ColumnDropper.mark_readonly(:users, column)
end
end
def down