Commit 0ef0150d8c5ff6fec88c64056ee8c788aed0aa14
Exists in
master
and in
4 other branches
Merge branch 'destroy_duplicate_keys' of /home/git/repositories/gitlab/gitlabhq
Showing
1 changed file
with
5 additions
and
0 deletions
Show diff stats
lib/tasks/migrate/migrate_keys.rake
1 | desc "GITLAB | Migrate SSH Keys" | 1 | desc "GITLAB | Migrate SSH Keys" |
2 | task migrate_keys: :environment do | 2 | task migrate_keys: :environment do |
3 | puts "This will add fingerprint to ssh keys in db" | 3 | puts "This will add fingerprint to ssh keys in db" |
4 | + puts "If you have duplicate keys https://github.com/gitlabhq/gitlabhq/issues/4453 all but the first will be deleted".yellow | ||
4 | ask_to_continue | 5 | ask_to_continue |
5 | 6 | ||
6 | Key.find_each(batch_size: 20) do |key| | 7 | Key.find_each(batch_size: 20) do |key| |
7 | if key.valid? && key.save | 8 | if key.valid? && key.save |
8 | print '.' | 9 | print '.' |
10 | + elsif key.fingerprint.present? | ||
11 | + puts "\nDeleting #{key.inspect}".yellow | ||
12 | + key.destroy | ||
9 | else | 13 | else |
10 | print 'F' | 14 | print 'F' |
11 | end | 15 | end |
12 | end | 16 | end |
17 | + print "\n" | ||
13 | end | 18 | end |
14 | 19 | ||
15 | 20 |