sqldb: delete wrong index names and add missing one
What changed, and why it matters
This commit fixes a database migration rollback script. When undoing the invoices-related database schema, the script previously tried to drop indexes that either had wrong names or did not exist, and it forgot to drop one index that actually exists. This is a cleanup/maintenance fix for a 'down' migration; it does not change normal runtime behavior or fix an active security vulnerability.
No immediate security action required. Treat as a normal maintenance patch. If deploying migrations, verify rollback tests pass after this change.
Security signals we found
Database migration correctness fix
No runtime code change
No authentication, authorization, or cryptographic change
No explicit security relevance stated by vendor
Evidence from the diff
The change is in sqldb/sqlc/migrations/000001_invoices.down.sql, the rollback for the invoices migration. It removes three DROP statements for indexes named invoice_payments_invoice_id_idx, invoice_payments_settled_at_idx, and the invoice_payments table, which apparently do not belong to this migration or have different names. It also adds the missing DROP INDEX IF EXISTS invoices_settled_at_idx before dropping the invoices table. The effect is to make the down-migration idempotent and correct, preventing migration failures during rollbacks.
Changed components
sqldb/sqlc/migrations/000001_invoices.down.sqlInspect captured patch +1 / −4
diff --git a/sqldb/sqlc/migrations/000001_invoices.down.sql b/sqldb/sqlc/migrations/000001_invoices.down.sql
index 0e275b3..4d1bd73 100644
--- a/sqldb/sqlc/migrations/000001_invoices.down.sql
+++ b/sqldb/sqlc/migrations/000001_invoices.down.sql
@@ -1,7 +1,3 @@
-DROP INDEX IF EXISTS invoice_payments_invoice_id_idx;
-DROP INDEX IF EXISTS invoice_payments_settled_at_idx;
-DROP TABLE IF EXISTS invoice_payments;
-
DROP INDEX IF EXISTS invoice_htlc_custom_records_htlc_id_idx;
DROP TABLE IF EXISTS invoice_htlc_custom_records;
@@ -11,6 +7,7 @@ DROP TABLE IF EXISTS invoice_htlcs;
DROP INDEX IF EXISTS invoice_feature_invoice_id_idx;
DROP TABLE IF EXISTS invoice_features;
+DROP INDEX IF EXISTS invoices_settled_at_idx;
DROP INDEX IF EXISTS invoices_created_at_idx;
DROP INDEX IF EXISTS invoices_state_idx;
DROP INDEX IF EXISTS invoices_payment_addr_idx;
Why this scored 15/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.