diff --git a/graph/db/sql_store.go b/graph/db/sql_store.go index fa7a49206..48a6509f9 100644 --- a/graph/db/sql_store.go +++ b/graph/db/sql_store.go @@ -1,6 +1,8 @@ package graphdb import ( + "fmt" + "github.com/lightningnetwork/lnd/sqldb" ) @@ -37,9 +39,21 @@ var _ V1Store = (*SQLStore)(nil) // NewSQLStore creates a new SQLStore instance given an open BatchedSQLQueries // 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{ db: db, KVStore: kvStore, - } + }, nil } diff --git a/graph/db/test_postgres.go b/graph/db/test_postgres.go index 7509a5907..2e38505f3 100644 --- a/graph/db/test_postgres.go +++ b/graph/db/test_postgres.go @@ -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 } diff --git a/graph/db/test_sqlite.go b/graph/db/test_sqlite.go index 601bba6fb..61373bfdd 100644 --- a/graph/db/test_sqlite.go +++ b/graph/db/test_sqlite.go @@ -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 }