Skip to content

Instantly share code, notes, and snippets.

@pnispel
Created October 23, 2018 20:40
Show Gist options
  • Save pnispel/4502dbf8854b2d623005fd1aa6f52aad to your computer and use it in GitHub Desktop.
Save pnispel/4502dbf8854b2d623005fd1aa6f52aad to your computer and use it in GitHub Desktop.
batch_size = 1000
start_id = LoginInformation.minimum(LoginInformation.primary_key) || 0
max_id = LoginInformation.maximum(LoginInformation.primary_key) || 0
end_id = [start_id + batch_size, max_id].min
while start_id <= max_id
LoginInformation.where("login_informations.id BETWEEN #{start_id} and #{end_id} AND temp_id_uuid_mappings.id = login_informations.id").update_all("uuid = temp_id_uuid_mappings.uuid FROM temp_id_uuid_mappings")
start_id += batch_size
end_id = [start_id + batch_size, max_id].min
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment