Description
It would be nice to return the number of performed migrations, as this can be logged when migrations are performed and when someone is looking at the logs, he can observe if the migrations have really been executed or no.
For example, imagine that "clumsy old me" or a colleague decides to change a database column, but without creating a new DB migration file, just edits an existing migration file. Now when the service is deployed and it automatically performs DB migrations upon startup, we can observe in the logs an entry like performed db migrations: 0
and easily guess that the DB changes were not applied, because they are placed in a previously performed DB migration.
I think a good place for this change might be the migrate.Up()
function and the API can look something like:
func (m *Migrate) Up() (int, error) {
...
}
if n, err := m.Up(); err != nil {
...
}
log.Println("performed migrations: ", n)