From 03507be3e690cc6cd73fdb8997fdfaad691b924d Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Mon, 8 Jul 2024 18:42:07 +0200 Subject: [PATCH] Fix typo from #237 I didn't adapt the logic right. This was hard to debug because, in integration tests, it caused the daemon to run `d.logger.WithError(err).Fatal("could not build migrations")`, which in turn runs `os.Exit` which ends the test right away (without flushing logs etc). I need to think how to improve this. One option is to override the `ExitFunc` in logrus with an assertion. --- cmd/soroban-rpc/internal/db/migration.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/soroban-rpc/internal/db/migration.go b/cmd/soroban-rpc/internal/db/migration.go index e3df2070..717871c4 100644 --- a/cmd/soroban-rpc/internal/db/migration.go +++ b/cmd/soroban-rpc/internal/db/migration.go @@ -131,12 +131,12 @@ func newGuardedDataMigration( } metaKey := "Migration" + uniqueMigrationName + "Done" previouslyMigrated, err := getMetaBool(ctx, migrationDB, metaKey) - if err != nil && !errors.Is(err, ErrEmptyDB) { + if !errors.Is(err, ErrEmptyDB) { err = errors.Join(err, migrationDB.Rollback()) return nil, err } latestLedger, err := NewLedgerEntryReader(db).GetLatestLedgerSequence(ctx) - if errors.Is(err, ErrEmptyDB) { + if !errors.Is(err, ErrEmptyDB) { err = errors.Join(err, migrationDB.Rollback()) return nil, fmt.Errorf("failed to get latest ledger sequence: %w", err) }