Commit 5ea374fe authored by Michael Kozono's avatar Michael Kozono

Guarantee the earliest key

parent 07e79989
...@@ -20,7 +20,7 @@ module Gitlab ...@@ -20,7 +20,7 @@ module Gitlab
end end
def add_keys_since(cutoff_datetime) def add_keys_since(cutoff_datetime)
start_key = Key.select(:id).where("created_at >= ?", cutoff_datetime).take start_key = Key.select(:id).where("created_at >= ?", cutoff_datetime).order('id ASC').take
if start_key if start_key
batch_add_keys_in_db_starting_from(start_key.id) batch_add_keys_in_db_starting_from(start_key.id)
end end
......
...@@ -49,6 +49,7 @@ describe Gitlab::BackgroundMigration::UpdateAuthorizedKeysFileSince do ...@@ -49,6 +49,7 @@ describe Gitlab::BackgroundMigration::UpdateAuthorizedKeysFileSince do
before do before do
Timecop.travel 1.day.from_now Timecop.travel 1.day.from_now
@key = create(:key) @key = create(:key)
create(:key) # other key
end end
it 'calls batch_add_keys_in_db_starting_from with the start key ID' do it 'calls batch_add_keys_in_db_starting_from with the start key ID' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment