AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 32 Bitcoin

sqldb/v2: Use `MigrationStream` for migrations

Public commit record

What the developer wrote

Authored by Viktor Torstensson

68/100 · Adequate
sqldb/v2: Use `MigrationStream` for migrations

This commit updates the `sqldb/v2` package to utilize the new
`MigrationStream` type for executing migrations, instead of passing
`[]MigrationConfig`'s directly.
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit refactors how LND's new sqldb/v2 package runs database migrations. It replaces a hand-rolled migration loop with a new MigrationStream abstraction, adds automatic SQLite backups before migrations, prevents accidental database downgrades, and rejects running migrations when the database is in a 'dirty' (partially failed) state. The changes are mostly defensive hardening and code cleanup rather than a fix for a known active vulnerability.

Recommended action

Treat this as a routine refactor with defensive hardening. Reviewers should verify that the new ProgrammaticMigrEntry callbacks are registered at the correct versions, that downgrade/dirty-state errors are handled gracefully by callers, and that the SQLite backup path does not leak sensitive database files to unexpected locations. No urgent security patch is indicated.

Security signals we found

01

New dirty-state guard aborts migrations if a previous migration failed

02

New downgrade guard prevents running older code against a newer schema

03

SQLite migrations now create a VACUUM INTO backup before upgrading

04

Migration tracking table name is now configurable per MigrationSet

05

Custom migration functions moved from MigrationConfig to golang-migrate programmatic migration entries

06

Removed direct context.Context and sqlc.Queries migration orchestration in favor of MigrationExecutor interface

Risk score

Why this scored 32/100

Our methodology →
Potential impact 8/30
Exploitability 5/25
Stealth signal 4/15
Affected reach 6/15
Confidence 6/10
Evidence quality 3/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.