Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EDSC-2157: Remove multiple access configurations from database
- Loading branch information
Showing
1 changed file
with
16 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace :access_configuration do | ||
task delete_multiples: ['environment'] do | ||
# Pre e2e access configurations could have multiple access methods. | ||
# This removes any extra options from the database. | ||
count = 0 | ||
AccessConfiguration.all.each do |access_configuration| | ||
access_methods = access_configuration.service_options.fetch('accessMethod', []) | ||
access_configuration.service_options = { | ||
'accessMethod' => Array.wrap(access_methods.first) | ||
} | ||
access_configuration.save | ||
count += 1 if access_methods.size > 1 | ||
end | ||
puts "Done! #{count} AccessConfigurations updated" | ||
end | ||
end |