It is good to know when a migration is not needed, but that is a valid state in a system.
So, why is there an error when all migrations already been ran?
Why are you communicating informational conditions using errors?
Errors should be reserved for errors.
Please return a struct from Up and Down which lists information conditions (stats, if you will).
Please remove the return of error when all migrations have been performed, and no changes would result.
Can't imagine when that would ever be a valid condition for an error.
No changes? Great! Sail the seas of cheese!
if migrateErr := m.Up(); migrateErr != nil {
// No change is not an error condition. It is the DESIRED condition.. .To be up to date.
if !errors.Is(migrateErr, migrate.ErrNoChange) {
return fmt.Errorf("cannot perform database migration: %w", migrateErr)
}
}
It is good to know when a migration is not needed, but that is a valid state in a system. So, why is there an error when all migrations already been ran? Why are you communicating informational conditions using errors? Errors should be reserved for errors. Please return a struct from Up and Down which lists information conditions (stats, if you will). Please remove the return of error when all migrations have been performed, and no changes would result. Can't imagine when that would ever be a valid condition for an error. No changes? Great! Sail the seas of cheese!