diff --git a/lnbits/extensions/watchonly/migrations.py b/lnbits/extensions/watchonly/migrations.py index 05c229b5..78eaa0ae 100644 --- a/lnbits/extensions/watchonly/migrations.py +++ b/lnbits/extensions/watchonly/migrations.py @@ -34,3 +34,50 @@ async def m001_initial(db): ); """ ) + + +async def m002_add_columns_to_adresses(db): + """ + Add 'branch_index', 'address_index', 'has_activity' and 'note' columns to the 'addresses' table + """ + + await db.execute( + "ALTER TABLE watchonly.addresses ADD COLUMN branch_index INTEGER NOT NULL DEFAULT 0;" + ) + await db.execute( + "ALTER TABLE watchonly.addresses ADD COLUMN address_index INTEGER NOT NULL DEFAULT 0;" + ) + await db.execute( + "ALTER TABLE watchonly.addresses ADD COLUMN has_activity BOOLEAN DEFAULT false;" + ) + await db.execute("ALTER TABLE watchonly.addresses ADD COLUMN note TEXT;") + + +async def m003_add_columns_to_wallets(db): + """ + Add 'type' and 'fingerprint' columns to the 'wallets' table + """ + + await db.execute("ALTER TABLE watchonly.wallets ADD COLUMN type TEXT;") + await db.execute( + "ALTER TABLE watchonly.wallets ADD COLUMN fingerprint TEXT NOT NULL;" + ) + + +async def m004_create_config_table(db): + """ + Allow the extension to persist and retrieve any number of config values. + Each user has its configurations saved as a JSON string + """ + + await db.execute( + """CREATE TABLE watchonly.config ( + "user" TEXT NOT NULL, + json_data TEXT NOT NULL + );""" + ) + + ### TODO: fix statspay dependcy first + # await db.execute( + # "DROP TABLE watchonly.wallets;" + # )