mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-12-02 08:59:27 +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:
@@ -148,9 +148,13 @@ func NewTestPostgresDB(t *testing.T, fixture *TestPgFixture) *PostgresStore {
|
||||
require.NoError(t, err)
|
||||
|
||||
cfg := fixture.GetConfig(dbName)
|
||||
store, err := NewPostgresStore(cfg, GetMigrations())
|
||||
store, err := NewPostgresStore(cfg)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.NoError(t, store.ApplyAllMigrations(
|
||||
context.Background(), GetMigrations()),
|
||||
)
|
||||
|
||||
return store
|
||||
}
|
||||
|
||||
@@ -172,7 +176,7 @@ func NewTestPostgresDBWithVersion(t *testing.T, fixture *TestPgFixture,
|
||||
|
||||
storeCfg := fixture.GetConfig(dbName)
|
||||
storeCfg.SkipMigrations = true
|
||||
store, err := NewPostgresStore(storeCfg, GetMigrations())
|
||||
store, err := NewPostgresStore(storeCfg)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = store.ExecuteMigrations(TargetVersion(version))
|
||||
|
||||
Reference in New Issue
Block a user