graph/db: add StoreOptions to NewSQLStore

This commit is contained in:
Elle Mouton
2025-05-23 11:00:29 +02:00
parent a0a20bd0d0
commit 149e1c7d35
3 changed files with 24 additions and 4 deletions

View File

@@ -1,6 +1,8 @@
package graphdb package graphdb
import ( import (
"fmt"
"github.com/lightningnetwork/lnd/sqldb" "github.com/lightningnetwork/lnd/sqldb"
) )
@@ -37,9 +39,21 @@ var _ V1Store = (*SQLStore)(nil)
// NewSQLStore creates a new SQLStore instance given an open BatchedSQLQueries // NewSQLStore creates a new SQLStore instance given an open BatchedSQLQueries
// storage backend. // storage backend.
func NewSQLStore(db BatchedSQLQueries, kvStore *KVStore) *SQLStore { func NewSQLStore(db BatchedSQLQueries, kvStore *KVStore,
options ...StoreOptionModifier) (*SQLStore, error) {
opts := DefaultOptions()
for _, o := range options {
o(opts)
}
if opts.NoMigration {
return nil, fmt.Errorf("the NoMigration option is not yet " +
"supported for SQL stores")
}
return &SQLStore{ return &SQLStore{
db: db, db: db,
KVStore: kvStore, KVStore: kvStore,
} }, nil
} }

View File

@@ -38,5 +38,8 @@ func NewTestDB(t testing.TB) V1Store {
}, },
) )
return NewSQLStore(executor, graphStore) store, err := NewSQLStore(executor, graphStore)
require.NoError(t, err)
return store
} }

View File

@@ -31,5 +31,8 @@ func NewTestDB(t testing.TB) V1Store {
}, },
) )
return NewSQLStore(executor, graphStore) store, err := NewSQLStore(executor, graphStore)
require.NoError(t, err)
return store
} }