From 3cbbe2a93d546e4e64c36a6a79e3c2355ced648b Mon Sep 17 00:00:00 2001 From: ChuckNorrison <2964146+ChuckNorrison@users.noreply.github.com> Date: Thu, 17 Nov 2022 15:44:59 +0100 Subject: [PATCH 1/6] fix integer to bigint for extensions Some more INTEGER to BIGINT conversion for postgresql database --- lnbits/extensions/lnurlp/migrations.py | 2 +- lnbits/extensions/offlineshop/migrations.py | 2 +- lnbits/extensions/paywall/migrations.py | 4 ++-- lnbits/extensions/satsdice/migrations.py | 6 +++--- lnbits/extensions/satspay/migrations.py | 4 ++-- lnbits/extensions/watchonly/migrations.py | 4 ++-- lnbits/extensions/withdraw/migrations.py | 8 ++++---- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lnbits/extensions/lnurlp/migrations.py b/lnbits/extensions/lnurlp/migrations.py index 81dd62f8..83a99c2c 100644 --- a/lnbits/extensions/lnurlp/migrations.py +++ b/lnbits/extensions/lnurlp/migrations.py @@ -8,7 +8,7 @@ async def m001_initial(db): id {db.serial_primary_key}, wallet TEXT NOT NULL, description TEXT NOT NULL, - amount INTEGER NOT NULL, + amount {db.big_int} NOT NULL, served_meta INTEGER NOT NULL, served_pr INTEGER NOT NULL ); diff --git a/lnbits/extensions/offlineshop/migrations.py b/lnbits/extensions/offlineshop/migrations.py index 84aea27e..4e668668 100644 --- a/lnbits/extensions/offlineshop/migrations.py +++ b/lnbits/extensions/offlineshop/migrations.py @@ -22,7 +22,7 @@ async def m001_initial(db): description TEXT NOT NULL, image TEXT, -- image/png;base64,... enabled BOOLEAN NOT NULL DEFAULT true, - price INTEGER NOT NULL, + price {db.big_int} NOT NULL, unit TEXT NOT NULL DEFAULT 'sat' ); """ diff --git a/lnbits/extensions/paywall/migrations.py b/lnbits/extensions/paywall/migrations.py index fa91e409..bef954f6 100644 --- a/lnbits/extensions/paywall/migrations.py +++ b/lnbits/extensions/paywall/migrations.py @@ -10,7 +10,7 @@ async def m001_initial(db): secret TEXT NOT NULL, url TEXT NOT NULL, memo TEXT NOT NULL, - amount INTEGER NOT NULL, + amount {db.big_int} NOT NULL, time TIMESTAMP NOT NULL DEFAULT """ + db.timestamp_now + """ @@ -32,7 +32,7 @@ async def m002_redux(db): url TEXT NOT NULL, memo TEXT NOT NULL, description TEXT NULL, - amount INTEGER DEFAULT 0, + amount {db.big_int} DEFAULT 0, time TIMESTAMP NOT NULL DEFAULT """ + db.timestamp_now + """, diff --git a/lnbits/extensions/satsdice/migrations.py b/lnbits/extensions/satsdice/migrations.py index 61298241..990123f2 100644 --- a/lnbits/extensions/satsdice/migrations.py +++ b/lnbits/extensions/satsdice/migrations.py @@ -10,7 +10,7 @@ async def m001_initial(db): title TEXT, min_bet INTEGER, max_bet INTEGER, - amount INTEGER DEFAULT 0, + amount {db.big_int} DEFAULT 0, served_meta INTEGER NOT NULL, served_pr INTEGER NOT NULL, multiplier FLOAT, @@ -32,7 +32,7 @@ async def m002_initial(db): CREATE TABLE satsdice.satsdice_withdraw ( id TEXT PRIMARY KEY, satsdice_pay TEXT, - value INTEGER DEFAULT 1, + value {db.big_int} DEFAULT 1, unique_hash TEXT UNIQUE, k1 TEXT, open_time INTEGER, @@ -51,7 +51,7 @@ async def m003_initial(db): CREATE TABLE satsdice.satsdice_payment ( payment_hash TEXT PRIMARY KEY, satsdice_pay TEXT, - value INTEGER, + value {db.big_int}, paid BOOL DEFAULT FALSE, lost BOOL DEFAULT FALSE ); diff --git a/lnbits/extensions/satspay/migrations.py b/lnbits/extensions/satspay/migrations.py index 87446c80..a9d61418 100644 --- a/lnbits/extensions/satspay/migrations.py +++ b/lnbits/extensions/satspay/migrations.py @@ -18,8 +18,8 @@ async def m001_initial(db): completelink TEXT, completelinktext TEXT, time INTEGER, - amount INTEGER, - balance INTEGER DEFAULT 0, + amount {db.big_int}, + balance {db.big_int} DEFAULT 0, timestamp TIMESTAMP NOT NULL DEFAULT """ + db.timestamp_now + """ diff --git a/lnbits/extensions/watchonly/migrations.py b/lnbits/extensions/watchonly/migrations.py index 76f7f951..dbe0c1a2 100644 --- a/lnbits/extensions/watchonly/migrations.py +++ b/lnbits/extensions/watchonly/migrations.py @@ -10,7 +10,7 @@ async def m001_initial(db): masterpub TEXT NOT NULL, title TEXT NOT NULL, address_no INTEGER NOT NULL DEFAULT 0, - balance INTEGER NOT NULL + balance {db.big_int} NOT NULL ); """ ) @@ -21,7 +21,7 @@ async def m001_initial(db): id TEXT NOT NULL PRIMARY KEY, address TEXT NOT NULL, wallet TEXT NOT NULL, - amount INTEGER NOT NULL + amount {db.big_int} NOT NULL ); """ ) diff --git a/lnbits/extensions/withdraw/migrations.py b/lnbits/extensions/withdraw/migrations.py index 5484277a..e30f88d0 100644 --- a/lnbits/extensions/withdraw/migrations.py +++ b/lnbits/extensions/withdraw/migrations.py @@ -8,8 +8,8 @@ async def m001_initial(db): id TEXT PRIMARY KEY, wallet TEXT, title TEXT, - min_withdrawable INTEGER DEFAULT 1, - max_withdrawable INTEGER DEFAULT 1, + min_withdrawable {db.big_int} DEFAULT 1, + max_withdrawable {db.big_int} DEFAULT 1, uses INTEGER DEFAULT 1, wait_time INTEGER, is_unique INTEGER DEFAULT 0, @@ -33,8 +33,8 @@ async def m002_change_withdraw_table(db): id TEXT PRIMARY KEY, wallet TEXT, title TEXT, - min_withdrawable INTEGER DEFAULT 1, - max_withdrawable INTEGER DEFAULT 1, + min_withdrawable {db.big_int} DEFAULT 1, + max_withdrawable {db.big_int} DEFAULT 1, uses INTEGER DEFAULT 1, wait_time INTEGER, is_unique INTEGER DEFAULT 0, From 4b408c1f0a02b461ef84d869efacfe95f56e9aa0 Mon Sep 17 00:00:00 2001 From: calle <93376500+callebtc@users.noreply.github.com> Date: Sat, 19 Nov 2022 14:32:17 -0600 Subject: [PATCH 2/6] Update migrations.py f string --- lnbits/extensions/paywall/migrations.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lnbits/extensions/paywall/migrations.py b/lnbits/extensions/paywall/migrations.py index bef954f6..9b3341fd 100644 --- a/lnbits/extensions/paywall/migrations.py +++ b/lnbits/extensions/paywall/migrations.py @@ -3,7 +3,7 @@ async def m001_initial(db): Initial paywalls table. """ await db.execute( - """ + f""" CREATE TABLE paywall.paywalls ( id TEXT PRIMARY KEY, wallet TEXT NOT NULL, @@ -25,7 +25,7 @@ async def m002_redux(db): """ await db.execute("ALTER TABLE paywall.paywalls RENAME TO paywalls_old") await db.execute( - """ + f""" CREATE TABLE paywall.paywalls ( id TEXT PRIMARY KEY, wallet TEXT NOT NULL, From 066015c05cc616824de0101cbe9aabd71cf82097 Mon Sep 17 00:00:00 2001 From: calle <93376500+callebtc@users.noreply.github.com> Date: Sat, 19 Nov 2022 14:33:18 -0600 Subject: [PATCH 3/6] Update migrations.py f string --- lnbits/extensions/satsdice/migrations.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lnbits/extensions/satsdice/migrations.py b/lnbits/extensions/satsdice/migrations.py index 990123f2..82ab35ba 100644 --- a/lnbits/extensions/satsdice/migrations.py +++ b/lnbits/extensions/satsdice/migrations.py @@ -3,7 +3,7 @@ async def m001_initial(db): Creates an improved satsdice table and migrates the existing data. """ await db.execute( - """ + f""" CREATE TABLE satsdice.satsdice_pay ( id TEXT PRIMARY KEY, wallet TEXT, @@ -28,7 +28,7 @@ async def m002_initial(db): Creates an improved satsdice table and migrates the existing data. """ await db.execute( - """ + f""" CREATE TABLE satsdice.satsdice_withdraw ( id TEXT PRIMARY KEY, satsdice_pay TEXT, @@ -47,7 +47,7 @@ async def m003_initial(db): Creates an improved satsdice table and migrates the existing data. """ await db.execute( - """ + f""" CREATE TABLE satsdice.satsdice_payment ( payment_hash TEXT PRIMARY KEY, satsdice_pay TEXT, From f70d30bfa62f7b27f7a4e8f20736047810b3a4d9 Mon Sep 17 00:00:00 2001 From: calle <93376500+callebtc@users.noreply.github.com> Date: Sat, 19 Nov 2022 14:34:13 -0600 Subject: [PATCH 4/6] Update migrations.py --- lnbits/extensions/withdraw/migrations.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lnbits/extensions/withdraw/migrations.py b/lnbits/extensions/withdraw/migrations.py index e30f88d0..0c6ed4fc 100644 --- a/lnbits/extensions/withdraw/migrations.py +++ b/lnbits/extensions/withdraw/migrations.py @@ -3,7 +3,7 @@ async def m001_initial(db): Creates an improved withdraw table and migrates the existing data. """ await db.execute( - """ + f""" CREATE TABLE withdraw.withdraw_links ( id TEXT PRIMARY KEY, wallet TEXT, @@ -28,7 +28,7 @@ async def m002_change_withdraw_table(db): Creates an improved withdraw table and migrates the existing data. """ await db.execute( - """ + f""" CREATE TABLE withdraw.withdraw_link ( id TEXT PRIMARY KEY, wallet TEXT, From f34e5496c069263fa3e40bb935fa30daa04e91f5 Mon Sep 17 00:00:00 2001 From: ChuckNorrison <2964146+ChuckNorrison@users.noreply.github.com> Date: Mon, 28 Nov 2022 19:00:43 +0100 Subject: [PATCH 5/6] add missing f-string for SQL --- lnbits/extensions/satspay/migrations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lnbits/extensions/satspay/migrations.py b/lnbits/extensions/satspay/migrations.py index a9d61418..3dacb031 100644 --- a/lnbits/extensions/satspay/migrations.py +++ b/lnbits/extensions/satspay/migrations.py @@ -4,7 +4,7 @@ async def m001_initial(db): """ await db.execute( - """ + f""" CREATE TABLE satspay.charges ( id TEXT NOT NULL PRIMARY KEY, "user" TEXT, From 4f05c6c12e284d4a322a9041d19f66d01afa205b Mon Sep 17 00:00:00 2001 From: ChuckNorrison <2964146+ChuckNorrison@users.noreply.github.com> Date: Mon, 28 Nov 2022 19:02:31 +0100 Subject: [PATCH 6/6] add missing f-string for SQL --- lnbits/extensions/watchonly/migrations.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lnbits/extensions/watchonly/migrations.py b/lnbits/extensions/watchonly/migrations.py index dbe0c1a2..e33062c9 100644 --- a/lnbits/extensions/watchonly/migrations.py +++ b/lnbits/extensions/watchonly/migrations.py @@ -3,7 +3,7 @@ async def m001_initial(db): Initial wallet table. """ await db.execute( - """ + f""" CREATE TABLE watchonly.wallets ( id TEXT NOT NULL PRIMARY KEY, "user" TEXT, @@ -16,7 +16,7 @@ async def m001_initial(db): ) await db.execute( - """ + f""" CREATE TABLE watchonly.addresses ( id TEXT NOT NULL PRIMARY KEY, address TEXT NOT NULL,