mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-17 00:22:33 +02:00
sqldb+invoices: add migration to fix incorrectly stored invoice expiries
Previously, when using the native schema, invoice expiries were incorrectly stored as 64-bit values (expiry in nanoseconds instead of seconds), causing overflow issues. Since we cannot determine the original values, we will set the expiries for existing invoices to 1 hour with this migration.
This commit is contained in:
2
sqldb/sqlc/migrations/000004_invoice_expiry_fix.down.sql
Normal file
2
sqldb/sqlc/migrations/000004_invoice_expiry_fix.down.sql
Normal file
@ -0,0 +1,2 @@
|
||||
-- Given that all expiries are changed in this migration we won't be able to
|
||||
-- roll back to the previous values.
|
14
sqldb/sqlc/migrations/000004_invoice_expiry_fix.up.sql
Normal file
14
sqldb/sqlc/migrations/000004_invoice_expiry_fix.up.sql
Normal file
@ -0,0 +1,14 @@
|
||||
-- Update the expiry for all records in the invoices table. This is needed as
|
||||
-- previously we stored raw time.Duration values which are 64 bit integers and
|
||||
-- are used to express duration in nanoseconds however the intent is to store
|
||||
-- invoice expiry in seconds.
|
||||
|
||||
-- Update the expiry to 86400 seconds (24 hours) for non-AMP invoices.
|
||||
UPDATE invoices
|
||||
SET expiry = 86400
|
||||
WHERE is_amp = FALSE;
|
||||
|
||||
-- Update the expiry to 2592000 seconds (30 days) for AMP invoices
|
||||
UPDATE invoices
|
||||
SET expiry = 2592000
|
||||
WHERE is_amp = TRUE;
|
Reference in New Issue
Block a user