discourse/db/migrate/20240520060901_add_requirement_to_user_fields.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

18 lines
390 B
Ruby
Raw Normal View History

# 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