Skip to content

Commit

Permalink
Merge pull request #215 from aws-containers/checkout-migration-error
Browse files Browse the repository at this point in the history
fix: Better handling of catalog db migration error value
  • Loading branch information
niallthomson authored Apr 15, 2023
2 parents 80808fc + 45830a4 commit 743f3da
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/catalog/repository/mysql_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -97,6 +100,8 @@ func createConnection(endpoint string, username string, password string, name st
return nil, err
}

log.Printf("Connected")

return db, nil
}

Expand All @@ -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
Expand Down

0 comments on commit 743f3da

Please sign in to comment.