Forum

ERROR 42P01 (undefined_table) relation "transaction_stats" does not exist

I have configured block scout for my private blockchain (which is using Geth). I am getting the following error on calling the URL
ERROR 42P01 (undefined_table) relation “transaction_stats” does not exist

In console it is showing
(Postgrex.Error) ERROR 42P01 (undefined_table) relation “pending_block_operations” does not exist

query: SELECT b0."number" FROM "blocks" AS b0 INNER JOIN "pending_block_operations" AS p1 ON p1."block_hash" = b0."hash" WHERE (p1."fetch_internal_transactions") AND (b0."consensus")
(db_connection 2.4.0) lib/db_connection.ex:1265: DBConnection.prepare_declare!/4
(db_connection 2.4.0) lib/db_connection.ex:1044: anonymous fn/4 in DBConnection.reduce/3
(elixir 1.12.2) lib/stream.ex:1517: anonymous fn/5 in Stream.resource/3
(elixir 1.12.2) lib/stream.ex:1719: Enumerable.Stream.do_each/4
(elixir 1.12.2) lib/stream.ex:880: Stream.do_transform/5
(elixir 1.12.2) lib/stream.ex:1719: Enumerable.Stream.do_each/4
(elixir 1.12.2) lib/enum.ex:3952: Enum.reduce/3
(ecto_sql 3.7.0) lib/ecto/adapters/sql.ex:1013: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4
(db_connection 2.4.0) lib/db_connection.ex:1512: DBConnection.run_transaction/4
(indexer 0.1.0) lib/indexer/fetcher/internal_transaction.ex:76: Indexer.Fetcher.InternalTransaction.init/3
(indexer 0.1.0) lib/indexer/buffered_task.ex:360: anonymous fn/5 in Indexer.BufferedTask.do_initial_stream/1
(elixir 1.12.2) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
(elixir 1.12.2) lib/task/supervised.ex:35: Task.Supervised.reply/5
(stdlib 3.15.2) proc_lib.erl:226: :proc_lib.init_p_do_apply/3

Function: #Function<1.14935980/0 in Indexer.BufferedTask.do_initial_stream/1>
Args: []
2021-10-14T20:06:29.611 fetcher=block_reward [error] Task #PID<0.1093.0> started from Indexer.Fetcher.BlockReward terminating
** (Postgrex.Error) ERROR 42703 (undefined_column) column sb0.base_fee_per_gas does not exist

query: SELECT s0."hash", s0."consensus", s0."difficulty", s0."gas_limit", s0."gas_used", s0."nonce", s0."number", s0."size", s0."timestamp", s0."total_difficulty", s0."refetch_needed", s0."base_fee_per_gas", s0."inserted_at", s0."updated_at", s0."miner_hash", s0."parent_hash" FROM (SELECT sb0."hash" AS "hash", sb0."consensus" AS "consensus", sb0."difficulty" AS "difficulty", sb0."gas_limit" AS "gas_limit", sb0."gas_used" AS "gas_used", sb0."nonce" AS "nonce", sb0."number" AS "number", sb0."size" AS "size", sb0."timestamp" AS "timestamp", sb0."total_difficulty" AS "total_difficulty", sb0."refetch_needed" AS "refetch_needed", sb0."base_fee_per_gas" AS "base_fee_per_gas", sb0."inserted_at" AS "inserted_at", sb0."updated_at" AS "updated_at", sb0."miner_hash" AS "miner_hash", sb0."parent_hash" AS "parent_hash" FROM "blocks" AS sb0 WHERE (sb0."consensus" = TRUE)) AS s0 LEFT OUTER JOIN (SELECT sb0."address_type" AS "address_type", sb0."reward" AS "reward", sb0."address_hash" AS "address_hash", sb0."block_hash" AS "block_hash", sb0."inserted_at" AS "inserted_at", sb0."updated_at" AS "updated_at" FROM "block_rewards" AS sb0 WHERE (sb0."address_type" = $1)) AS s1 ON s1."block_hash" = s0."hash" WHERE (s1."block_hash" IS NULL)
(db_connection 2.4.0) lib/db_connection.ex:1265: DBConnection.prepare_declare!/4
(db_connection 2.4.0) lib/db_connection.ex:1044: anonymous fn/4 in DBConnection.reduce/3
(elixir 1.12.2) lib/stream.ex:1517: anonymous fn/5 in Stream.resource/3
(elixir 1.12.2) lib/stream.ex:1719: Enumerable.Stream.do_each/4
(elixir 1.12.2) lib/stream.ex:880: Stream.do_transform/5
(elixir 1.12.2) lib/stream.ex:1719: Enumerable.Stream.do_e

In order to fix missing columns, you should run DB migrations from the application instance with mix do.ecto.create, ecto.migrate. For some reason, Blockscout DB schema is stale on your instance.