From cac68f0a739018a7888b198a5b2aa7ac9e56b0f0 Mon Sep 17 00:00:00 2001 From: otherview Date: Wed, 20 Sep 2023 18:05:28 +0100 Subject: [PATCH] check full error --- go/enclave/storage/init/migration/db_migration.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/go/enclave/storage/init/migration/db_migration.go b/go/enclave/storage/init/migration/db_migration.go index 31cfaaab36..15815ebfa5 100644 --- a/go/enclave/storage/init/migration/db_migration.go +++ b/go/enclave/storage/init/migration/db_migration.go @@ -16,7 +16,7 @@ import ( "github.com/obscuronet/go-obscuro/go/enclave/storage/enclavedb" ) -const currentFileKey = "CURRENT_FILE" +const currentMigrationVersionKey = "CURRENT_MIGRATION_VERSION" func DBMigration(db *sql.DB, sqlFiles embed.FS, logger gethlog.Logger) error { migrationFiles, err := readMigrationFiles(sqlFiles) @@ -27,7 +27,7 @@ func DBMigration(db *sql.DB, sqlFiles embed.FS, logger gethlog.Logger) error { maxMigration := int64(len(migrationFiles)) var maxDB int64 - config, err := enclavedb.FetchConfig(db, currentFileKey) + config, err := enclavedb.FetchConfig(db, currentMigrationVersionKey) if err != nil { // first time there is no entry, so we assume nothing was executed if errors.Is(err, errutil.ErrNotFound) { @@ -48,6 +48,8 @@ func DBMigration(db *sql.DB, sqlFiles embed.FS, logger gethlog.Logger) error { } err = executeMigration(db, string(content), i) if err != nil { + fmt.Println(err) + logger.Error(fmt.Sprintf("%s", err.Error())) return fmt.Errorf("unable to execute migration for %s - %w", migrationFiles[i].Name(), err) } logger.Info("Successfully executed", "file", migrationFiles[i].Name(), "index", i) @@ -66,7 +68,7 @@ func executeMigration(db *sql.DB, content string, migrationOrder int64) error { return err } - _, err = enclavedb.WriteConfigToTx(tx, currentFileKey, big.NewInt(migrationOrder).Bytes()) + _, err = enclavedb.WriteConfigToTx(tx, currentMigrationVersionKey, big.NewInt(migrationOrder).Bytes()) if err != nil { return err }