mirror of
https://github.com/LBRYFoundation/lbry-sdk.git
synced 2025-08-23 17:27:25 +00:00
Add migrator for the new peer
table
This commit is contained in:
parent
c832f8ffbb
commit
6bff298d1e
3 changed files with 24 additions and 1 deletions
|
@ -50,7 +50,7 @@ class DatabaseComponent(Component):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_current_db_revision():
|
def get_current_db_revision():
|
||||||
return 13
|
return 14
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def revision_filename(self):
|
def revision_filename(self):
|
||||||
|
|
|
@ -33,6 +33,8 @@ def migrate_db(conf, start, end):
|
||||||
from .migrate11to12 import do_migration
|
from .migrate11to12 import do_migration
|
||||||
elif current == 12:
|
elif current == 12:
|
||||||
from .migrate12to13 import do_migration
|
from .migrate12to13 import do_migration
|
||||||
|
elif current == 13:
|
||||||
|
from .migrate13to14 import do_migration
|
||||||
else:
|
else:
|
||||||
raise Exception(f"DB migration of version {current} to {current+1} is not available")
|
raise Exception(f"DB migration of version {current} to {current+1} is not available")
|
||||||
try:
|
try:
|
||||||
|
|
21
lbry/lbry/extras/daemon/migrator/migrate13to14.py
Normal file
21
lbry/lbry/extras/daemon/migrator/migrate13to14.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
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("""
|
||||||
|
create table if not exists peer (
|
||||||
|
node_id char(96) not null primary key,
|
||||||
|
address text not null,
|
||||||
|
udp_port integer not null,
|
||||||
|
tcp_port integer,
|
||||||
|
unique (address, udp_port)
|
||||||
|
);
|
||||||
|
""")
|
||||||
|
|
||||||
|
connection.commit()
|
||||||
|
connection.close()
|
Loading…
Add table
Reference in a new issue