Comment out update query in migration script due to run length concerns on a large existing database.

pull/1140/head
svenski123 6 years ago committed by Amanda Sposito
parent 3b45474e36
commit a3364385c6
  1. 31
      apps/explorer/priv/repo/migrations/20181106152300_add_nonce_to_addresses.exs
  2. 30
      apps/explorer/priv/repo/migrations/201811061523_add_nonce_to_addresses.exs

@ -0,0 +1,31 @@
defmodule Explorer.Repo.Migrations.AddNonceToAddresses do
use Ecto.Migration
def up do
# Add nonce
alter table(:addresses) do
add(:nonce, :integer)
end
# Populate nonce field from transactions table
# Commented out due to running time concerns
# execute("""
# WITH t AS (
# SELECT from_address_hash AS hash, MAX(nonce) AS nonce
# FROM transactions
# GROUP BY hash
# )
# UPDATE addresses AS a
# SET nonce = t.nonce
# FROM t
# WHERE a.hash = t.hash
# """)
end
def down do
# Remove nonce
alter table(:addresses) do
remove(:nonce)
end
end
end

@ -1,30 +0,0 @@
defmodule Explorer.Repo.Migrations.AddNonceToAddresses do
use Ecto.Migration
def up do
# Add nonce
alter table(:addresses) do
add(:nonce, :integer)
end
# Populate nonce field from transactions table
execute("""
WITH t AS (
SELECT from_address_hash AS hash, MAX(nonce) AS nonce
FROM transactions
GROUP BY hash
)
UPDATE addresses AS a
SET nonce = t.nonce
FROM t
WHERE a.hash = t.hash
""")
end
def down do
# Remove nonce
alter table(:addresses) do
remove(:nonce)
end
end
end
Loading…
Cancel
Save