* Introduce ProfileFieldGroup model * Make profile_fields_groups name column unique * Fix some specs * feat: allow the page to work again * Add guard clause to data update script * Remove unused file * Fix specs * Add foreign key Co-authored-by: Ridhwana <ridhwana.khan16@gmail.com>
16 lines
498 B
Ruby
16 lines
498 B
Ruby
module DataUpdateScripts
|
|
class MigrateProfileFieldGroups
|
|
def run
|
|
# ensure we can run this after the group column gets removed
|
|
return unless "group".in?(ProfileField.column_names)
|
|
|
|
profile_field_groups = Hash.new do |hash, key|
|
|
hash[key] = ProfileFieldGroup.find_or_create_by(name: key)
|
|
end
|
|
|
|
ProfileField.find_each do |profile_field|
|
|
profile_field.update(profile_field_group: profile_field_groups[profile_field.group])
|
|
end
|
|
end
|
|
end
|
|
end
|