From 45830a496ee7eacbc47bac52abca137b9fd8869f Mon Sep 17 00:00:00 2001 From: Niall Thomson Date: Sat, 15 Apr 2023 01:06:41 +0000 Subject: [PATCH] Better handling of catalog db migration error value --- src/catalog/repository/mysql_repository.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/catalog/repository/mysql_repository.go b/src/catalog/repository/mysql_repository.go index fc88717ee..19bad7e77 100644 --- a/src/catalog/repository/mysql_repository.go +++ b/src/catalog/repository/mysql_repository.go @@ -56,6 +56,9 @@ func newMySQLRepository(config config.DatabaseConfiguration) (Repository, error) log.Println("Error: Failed to run migration", err) return nil, err } + log.Printf("Schema migration applied") + } else { + log.Printf("Skipping schema migration") } var readerDb *sqlx.DB @@ -97,6 +100,8 @@ func createConnection(endpoint string, username string, password string, name st return nil, err } + log.Printf("Connected") + return db, nil } @@ -112,9 +117,12 @@ func migrateMySQL(connectionString string) error { return err } - if err := m.Up(); err != migrate.ErrNoChange { - log.Println("Error: Failed to apply migration", err) - return err + err = m.Up() + if err != nil { + if err != migrate.ErrNoChange { + log.Println("Error: Failed to apply migration", err) + return err + } } return nil