From 953b8dab769ccdca2d45f87ad36f419e02003a33 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Fri, 8 Jan 2021 17:30:41 -0300 Subject: [PATCH] check if constraint is NOT there before creating --- lbry/blockchain/sync/claims.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lbry/blockchain/sync/claims.py b/lbry/blockchain/sync/claims.py index c3c6add3b..7d3625710 100644 --- a/lbry/blockchain/sync/claims.py +++ b/lbry/blockchain/sync/claims.py @@ -165,16 +165,16 @@ def claims_insert( @event_emitter("blockchain.sync.claims.indexes", "steps") def claims_constraints_and_indexes(p: ProgressContext): - is_postgres = p.ctx.is_postgres and p.ctx.pg_has_pk_constraint('claim') + should_run = p.ctx.is_postgres and not p.ctx.pg_has_pk_constraint('claim') p.start(2 + len(pg_add_claim_and_tag_constraints_and_indexes)) - if is_postgres: + if should_run: p.ctx.execute_notx(text("VACUUM ANALYZE claim;")) p.step() - if is_postgres: + if should_run: p.ctx.execute_notx(text("VACUUM ANALYZE tag;")) p.step() for constraint in pg_add_claim_and_tag_constraints_and_indexes: - if is_postgres: + if should_run: p.ctx.execute(text(constraint)) p.step()