mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-11 08:13:00 +02: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:
@@ -355,6 +355,18 @@ func (t *TransactionExecutor[Q]) ExecTx(ctx context.Context,
|
||||
)
|
||||
}
|
||||
|
||||
// DB is an interface that represents a generic SQL database. It provides
|
||||
// methods to apply migrations and access the underlying database connection.
|
||||
type DB interface {
|
||||
// GetBaseDB returns the underlying BaseDB instance.
|
||||
GetBaseDB() *BaseDB
|
||||
|
||||
// ApplyAllMigrations applies all migrations to the database including
|
||||
// both sqlc and custom in-code migrations.
|
||||
ApplyAllMigrations(ctx context.Context,
|
||||
customMigrations []MigrationConfig) error
|
||||
}
|
||||
|
||||
// BaseDB is the base database struct that each implementation can embed to
|
||||
// gain some common functionality.
|
||||
type BaseDB struct {
|
||||
|
Reference in New Issue
Block a user