mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-12-02 00:51:14 +01:00
sqldb: separate migration execution from construction
This commit separates the execution of SQL and in-code migrations from their construction. This change is necessary because, currently, the SQL schema is migrated during the construction phase in the lncfg package. However, migrations are typically executed when individual stores are constructed within the configuration builder.
This commit is contained in:
@@ -2,7 +2,15 @@
|
||||
|
||||
package sqldb
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
// Make sure SqliteStore implements the DB interface.
|
||||
_ DB = (*SqliteStore)(nil)
|
||||
)
|
||||
|
||||
// SqliteStore is a database store implementation that uses a sqlite backend.
|
||||
type SqliteStore struct {
|
||||
@@ -16,3 +24,17 @@ type SqliteStore struct {
|
||||
func NewSqliteStore(cfg *SqliteConfig, dbPath string) (*SqliteStore, error) {
|
||||
return nil, fmt.Errorf("SQLite backend not supported in WebAssembly")
|
||||
}
|
||||
|
||||
// GetBaseDB returns the underlying BaseDB instance for the SQLite store.
|
||||
// It is a trivial helper method to comply with the sqldb.DB interface.
|
||||
func (s *SqliteStore) GetBaseDB() *BaseDB {
|
||||
return s.BaseDB
|
||||
}
|
||||
|
||||
// ApplyAllMigrations applies both the SQLC and custom in-code migrations to
|
||||
// the SQLite database.
|
||||
func (s *SqliteStore) ApplyAllMigrations(context.Context,
|
||||
[]MigrationConfig) error {
|
||||
|
||||
return fmt.Errorf("SQLite backend not supported in WebAssembly")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user