|
|
|
@ -1,11 +1,17 @@ |
|
|
|
|
defmodule GiantAddressMigrator do |
|
|
|
|
@moduledoc "Migrate away from Address join tables." |
|
|
|
|
|
|
|
|
|
require Logger |
|
|
|
|
|
|
|
|
|
alias Explorer.Repo |
|
|
|
|
|
|
|
|
|
def migrate do |
|
|
|
|
for n <- 1..20 do |
|
|
|
|
chunk_size = 500_000 |
|
|
|
|
lower = n * chunk_size - chunk_size |
|
|
|
|
upper = n * chunk_size |
|
|
|
|
|
|
|
|
|
IO.inspect("fetching results between #{lower} and #{upper}") |
|
|
|
|
Logger.info("fetching results between #{lower} and #{upper}") |
|
|
|
|
work_on_transactions_between_ids(lower, upper) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -20,8 +26,8 @@ defmodule GiantAddressMigrator do |
|
|
|
|
; |
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
{:ok, result} = Explorer.Repo.query(query, []) |
|
|
|
|
IO.inspect("got em!") |
|
|
|
|
{:ok, result} = Repo.query(query, []) |
|
|
|
|
Logger.info("got em!") |
|
|
|
|
|
|
|
|
|
result.rows |
|
|
|
|
|> Enum.each(&sweet_update/1) |
|
|
|
@ -32,7 +38,7 @@ defmodule GiantAddressMigrator do |
|
|
|
|
UPDATE transactions SET from_address_id = $1, to_address_id = $2 WHERE id = $3 |
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
{:ok, status} = Explorer.Repo.query(query, [from_address_id, to_address_id, transaction_id]) |
|
|
|
|
{:ok, _status} = Repo.query(query, [from_address_id, to_address_id, transaction_id]) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def sweet_update(_), do: nil |
|
|
|
|