Skip to content

Commit 847fdff

Browse files
committed
lnd: skip network validation when migrations are skipped
Skip the chain_params network check when startup is explicitly configured to skip SQL migrations. In that mode the schema is assumed to already be managed externally, and the chain_params table may not exist yet. Avoid failing startup on a missing table in this path.
1 parent debb31d commit 847fdff

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

config_builder.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,15 +1248,22 @@ func (d *DefaultDatabaseBuilder) BuildDatabase(
12481248
// (e.g. mainnet → testnet), which would otherwise lead to
12491249
// silent data corruption. This check applies to all native SQL
12501250
// backends.
1251-
chainParamsStore := chainparams.NewStore(baseDB)
1252-
err = chainParamsStore.ValidateNetwork(
1253-
ctx, d.cfg.ActiveNetParams.Params,
1254-
)
1255-
if err != nil {
1256-
cleanUp()
1257-
d.logger.Error(err)
1251+
//
1252+
// If migrations are explicitly skipped, we also skip this check
1253+
// because the chain_params table may not exist yet.
1254+
if !d.cfg.DB.Postgres.SkipMigrations &&
1255+
!d.cfg.DB.Sqlite.SkipMigrations {
1256+
1257+
chainParamsStore := chainparams.NewStore(baseDB)
1258+
err = chainParamsStore.ValidateNetwork(
1259+
ctx, d.cfg.ActiveNetParams.Params,
1260+
)
1261+
if err != nil {
1262+
cleanUp()
1263+
d.logger.Error(err)
12581264

1259-
return nil, nil, err
1265+
return nil, nil, err
1266+
}
12601267
}
12611268

12621269
// Create the invoice store.

0 commit comments

Comments
 (0)