Skip to content

Instantly share code, notes, and snippets.

@marciok
Last active December 11, 2015 16:48
Show Gist options
  • Save marciok/4629969 to your computer and use it in GitHub Desktop.
Save marciok/4629969 to your computer and use it in GitHub Desktop.
Commands to clean the data base
# Para deletar o conteudo de dentro da variavel
b.map(&:delete)
# Comando para tirar o heroku da manuntenção para ser executado no terminal: heroku maintenance:off -a battle-server-mock
# Scritpt que o Erich me passou
count = 0
total = 0
ids = Challenge.all.map(&:id)
Battle.nin(challenge_id: ids).batch_size(1000).no_timeout.each do |battle|
unless battle.valid?
battle.delete
puts "Deleted: #{count += 1}"
end
total += 1
puts "Total: #{total}" if total % 1000 == 0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment