paymentsdb: fix duplicate interface check and down migration drop order
What changed, and why it matters
This commit is a minor cleanup in LND's payment database code. It removes a duplicate compile-time type check and reorders two table-drop statements in a database downgrade script. The author notes the reordering was not actually a bug because the database already uses CASCADE deletes. There is no apparent security vulnerability here.
No security action required. Treat as routine code maintenance. If reviewing migration safety, verify downgrade path in a non-production environment as standard practice.
Security signals we found
No security-relevant code change identified
Migration script reordering only affects database downgrade path
Commit message explicitly downgrades security relevance ('This was not a bug in the first place')
Evidence from the diff
The diff makes two changes in paymentsdb: (1) removes a redundant var _ DB = (*SQLStore)(nil) compile-time interface assertion that already existed elsewhere; (2) swaps the order of DROP TABLE statements in migration 000010_payments.down.sql so payment_intents is dropped before payments, matching foreign-key dependency order. The commit message explicitly states this was not a bug because CASCADE on payment deletion already handled dependencies. No functional behavior change is introduced for normal runtime operations.
Changed components
payments/db/sql_store.gosqldb/sqlc/migrations/000010_payments.down.sqlInspect captured patch +6 / −9
diff --git a/payments/db/sql_store.go b/payments/db/sql_store.go
index 9644266..3637a98 100644
--- a/payments/db/sql_store.go
+++ b/payments/db/sql_store.go
@@ -132,9 +132,6 @@ func NewSQLStore(cfg *SQLStoreConfig, db BatchedSQLQueries,
}, nil
}
-// A compile-time constraint to ensure SQLStore implements DB.
-var _ DB = (*SQLStore)(nil)
-
// fetchPaymentWithCompleteData fetches a payment with all its related data
// including attempts, hops, and custom records from the database.
// This is a convenience wrapper around the batch loading functions for single
diff --git a/sqldb/sqlc/migrations/000010_payments.down.sql b/sqldb/sqlc/migrations/000010_payments.down.sql
index 62b19cb..68f19f7 100644
--- a/sqldb/sqlc/migrations/000010_payments.down.sql
+++ b/sqldb/sqlc/migrations/000010_payments.down.sql
@@ -40,15 +40,15 @@ DROP INDEX IF EXISTS idx_htlc_attempt_time;
DROP TABLE IF EXISTS payment_htlc_attempts;
-- ─────────────────────────────────────────────
--- Drop payments table and its indexes.
+-- Drop payment intents table and its indexes.
-- ─────────────────────────────────────────────
-DROP INDEX IF EXISTS idx_payments_created_at;
-DROP TABLE IF EXISTS payments;
+DROP INDEX IF EXISTS idx_payment_intents_type;
+DROP TABLE IF EXISTS payment_intents;
-- ─────────────────────────────────────────────
--- Drop payment intents table and its indexes.
+-- Drop payments table and its indexes.
-- ─────────────────────────────────────────────
-DROP INDEX IF EXISTS idx_payment_intents_type;
-DROP TABLE IF EXISTS payment_intents;
\ No newline at end of file
+DROP INDEX IF EXISTS idx_payments_created_at;
+DROP TABLE IF EXISTS payments;
\ No newline at end of file
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.