Blockchain explorer for Ethereum based network and a tool for inspecting and analyzing EVM based blockchains.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
blockscout/apps/explorer/lib/mix/tasks/migrate.transaction.info.ex

33 lines
783 B

defmodule Mix.Tasks.Migrate.Transaction.Info do
use Mix.Task
alias Ecto.Adapters.SQL
alias Explorer.Repo
@shortdoc "Migrates transaction info to internal transaction"
@moduledoc """
This task is reponsible to populate the `transaction_index` and
`block_number` at the `internal_transactions` table, using the
`transactions` info.
"""
def run(_args) do
{:ok, _} = Application.ensure_all_started(:explorer)
SQL.query(
Repo,
"""
UPDATE internal_transactions
SET
block_number = transactions.block_number,
transaction_index = transactions.index
FROM transactions
WHERE internal_transactions.transaction_hash = transactions.hash;
""",
[],
timeout: :infinity
)
end
end