From fe25bf7b44e45417fc57bcda008afc86e35e03b3 Mon Sep 17 00:00:00 2001 From: goodsoft Date: Tue, 26 Mar 2019 22:36:13 +0200 Subject: [PATCH] Add a migration to mark all invalid blocks as non-consensus (#1644) --- .../20190326202921_lose_consensus_for_invalid_blocks.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 apps/explorer/priv/repo/migrations/scripts/20190326202921_lose_consensus_for_invalid_blocks.sql diff --git a/apps/explorer/priv/repo/migrations/scripts/20190326202921_lose_consensus_for_invalid_blocks.sql b/apps/explorer/priv/repo/migrations/scripts/20190326202921_lose_consensus_for_invalid_blocks.sql new file mode 100644 index 0000000000..38e8678484 --- /dev/null +++ b/apps/explorer/priv/repo/migrations/scripts/20190326202921_lose_consensus_for_invalid_blocks.sql @@ -0,0 +1,6 @@ +UPDATE blocks SET consensus = FALSE +WHERE number IN ( + SELECT b0.number - 1 FROM "blocks" AS b0 + LEFT JOIN "blocks" AS b1 ON (b0."parent_hash" = b1."hash") AND b1."consensus" + WHERE b0."number" > 0 AND b0."consensus" AND b1."hash" IS NULL +);