mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-27 14:11:04 +02:00
lnd: plug in graph SQL migration into dev build
This commit plugs in the graph kvdb-to-sql migration for builds containing the `test_native_sql` tag. This will allow us to perform local tests and write itests for the migration without exposing it to the production release build.
This commit is contained in:
@@ -1097,7 +1097,7 @@ func (d *DefaultDatabaseBuilder) BuildDatabase(
|
||||
// migration's version (7), it will be skipped permanently,
|
||||
// regardless of the flag.
|
||||
if !d.cfg.DB.SkipNativeSQLMigration {
|
||||
migrationFn := func(tx *sqlc.Queries) error {
|
||||
invoiceMig := func(tx *sqlc.Queries) error {
|
||||
err := invoices.MigrateInvoicesToSQL(
|
||||
ctx, dbs.ChanStateDB.Backend,
|
||||
dbs.ChanStateDB, tx,
|
||||
@@ -1119,11 +1119,22 @@ func (d *DefaultDatabaseBuilder) BuildDatabase(
|
||||
// Make sure we attach the custom migration function to
|
||||
// the correct migration version.
|
||||
for i := 0; i < len(migrations); i++ {
|
||||
if migrations[i].Version != invoiceMigration {
|
||||
version := migrations[i].Version
|
||||
if version == invoiceMigration {
|
||||
migrations[i].MigrationFn = invoiceMig
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
migrations[i].MigrationFn = migrationFn
|
||||
migFn, ok := getSQLMigration(
|
||||
ctx, version, dbs.ChanStateDB.Backend,
|
||||
*d.cfg.ActiveNetParams.GenesisHash,
|
||||
)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
migrations[i].MigrationFn = migFn
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user