forked from pressly/goose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
provider_errors.go
38 lines (31 loc) · 1.16 KB
/
provider_errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package goose
import (
"errors"
"fmt"
)
var (
// ErrVersionNotFound when a migration version is not found.
ErrVersionNotFound = errors.New("version not found")
// ErrAlreadyApplied when a migration has already been applied.
ErrAlreadyApplied = errors.New("already applied")
// ErrNoMigrations is returned by [NewProvider] when no migrations are found.
ErrNoMigrations = errors.New("no migrations found")
// errInvalidVersion is returned when a migration version is invalid.
errInvalidVersion = errors.New("version must be greater than 0")
)
// PartialError is returned when a migration fails, but some migrations already got applied.
type PartialError struct {
// Applied are migrations that were applied successfully before the error occurred. May be
// empty.
Applied []*MigrationResult
// Failed contains the result of the migration that failed. Cannot be nil.
Failed *MigrationResult
// Err is the error that occurred while running the migration and caused the failure.
Err error
}
func (e *PartialError) Error() string {
return fmt.Sprintf(
"partial migration error (type:%s,version:%d): %v",
e.Failed.Source.Type, e.Failed.Source.Version, e.Err,
)
}