From dd5b9ca81b19ca486fd5cec554633df7b1773449 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Wed, 9 Feb 2022 00:08:23 -0300 Subject: [PATCH] add migrator to set head blobs should_announce=0 --- lbry/extras/daemon/migrator/dbmigrator.py | 2 ++ lbry/extras/daemon/migrator/migrate15to16.py | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 lbry/extras/daemon/migrator/migrate15to16.py diff --git a/lbry/extras/daemon/migrator/dbmigrator.py b/lbry/extras/daemon/migrator/dbmigrator.py index a2b1211e7..7542adab9 100644 --- a/lbry/extras/daemon/migrator/dbmigrator.py +++ b/lbry/extras/daemon/migrator/dbmigrator.py @@ -37,6 +37,8 @@ def migrate_db(conf, start, end): from .migrate13to14 import do_migration elif current == 14: from .migrate14to15 import do_migration + elif current == 15: + from .migrate15to16 import do_migration else: raise Exception(f"DB migration of version {current} to {current+1} is not available") try: diff --git a/lbry/extras/daemon/migrator/migrate15to16.py b/lbry/extras/daemon/migrator/migrate15to16.py new file mode 100644 index 000000000..0c2d9da41 --- /dev/null +++ b/lbry/extras/daemon/migrator/migrate15to16.py @@ -0,0 +1,17 @@ +import os +import sqlite3 + + +def do_migration(conf): + db_path = os.path.join(conf.data_dir, "lbrynet.sqlite") + connection = sqlite3.connect(db_path) + cursor = connection.cursor() + + cursor.executescript(""" + update blob set should_announce=0 + where should_announce=1 and + blob.blob_hash in (select stream_blob.blob_hash from stream_blob where position=0); + """) + + connection.commit() + connection.close()