lnd: plug in graph SQL migration into dev build

This commit plugs in the graph kvdb-to-sql migration for builds
containing the `test_native_sql` tag. This will allow us to perform
local tests and write itests for the migration without exposing it to
the production release build.
This commit is contained in:
Elle Mouton
2025-07-11 13:35:00 +02:00
parent 223cec442b
commit 902611d86a
4 changed files with 72 additions and 3 deletions

View File

@@ -3,9 +3,13 @@
package lnd
import (
"context"
"github.com/btcsuite/btcd/chaincfg/chainhash"
graphdb "github.com/lightningnetwork/lnd/graph/db"
"github.com/lightningnetwork/lnd/kvdb"
"github.com/lightningnetwork/lnd/sqldb"
"github.com/lightningnetwork/lnd/sqldb/sqlc"
)
// getGraphStore returns a graphdb.V1Store backed by a graphdb.KVStore
@@ -16,3 +20,15 @@ func (d *DefaultDatabaseBuilder) getGraphStore(_ *sqldb.BaseDB,
return graphdb.NewKVStore(kvBackend, opts...)
}
// getSQLMigration returns a migration function for the given version.
//
// NOTE: this is a no-op for the production build since all migrations that are
// in production will also be in development builds, and so they are not
// defined behind a build tag.
func getSQLMigration(ctx context.Context, version int,
kvBackend kvdb.Backend,
chain chainhash.Hash) (func(tx *sqlc.Queries) error, bool) {
return nil, false
}