discourse/db/migrate/20240520060901_add_requirement_to_user_fields.rb
Ted Johansson 7b437c9401
FEATURE: Implement new required options in admin user fields UI (#27079)
We're planning to implement a feature that allows adding required fields for existing users. This PR does some preparatory refactoring to make that possible. There should be no changes to existing behaviour. Just a small update to the admin UI.
2024-05-23 19:18:25 +08:00

18 lines
390 B
Ruby

# frozen_string_literal: true
class AddRequirementToUserFields < ActiveRecord::Migration[7.0]
def up
add_column :user_fields, :requirement, :integer, null: false, default: 0
execute <<~SQL
UPDATE user_fields
SET requirement =
(CASE WHEN required IS NOT TRUE THEN 0 ELSE 2 END)
SQL
end
def down
remove_column :user_fields, :requirement
end
end