From 8a3b960a85d7592149a95b29d83194896b5a7edb Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Mon, 3 Aug 2020 22:36:14 -0400 Subject: [PATCH] delete tag when rewinding --- lbry/blockchain/sync/blocks.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lbry/blockchain/sync/blocks.py b/lbry/blockchain/sync/blocks.py index 73936640b..9c4ddc91c 100644 --- a/lbry/blockchain/sync/blocks.py +++ b/lbry/blockchain/sync/blocks.py @@ -4,7 +4,7 @@ from sqlalchemy import table, bindparam, text, func, union from sqlalchemy.future import select from sqlalchemy.schema import CreateTable -from lbry.db.tables import Block as BlockTable, TX, TXO, TXI, Claim, Support +from lbry.db.tables import Block as BlockTable, TX, TXO, TXI, Claim, Tag, Support from lbry.db.tables import ( pg_add_tx_constraints_and_indexes, pg_add_txo_constraints_and_indexes, @@ -199,6 +199,11 @@ def rewind(height: int, p: ProgressContext): TXI.delete().where(TXI.c.height >= height), TXO.delete().where(TXO.c.height >= height), TX.delete().where(TX.c.height >= height), + Tag.delete().where( + Tag.c.claim_hash.in_( + select(Claim.c.claim_hash).where(Claim.c.height >= height) + ) + ), Claim.delete().where(Claim.c.height >= height), Support.delete().where(Support.c.height >= height), ]