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:
Andras Banki-Horvath committed 2025-01-23 09:10:59 +01:00
1 parent b789fb2db3
commit 91c3e1496f
8 files changed
+137 -57

No files matched your search

+6 -2
View File
@@ -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))