forked from pressly/goose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
provider_types.go
55 lines (46 loc) · 1.59 KB
/
provider_types.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package goose
import "time"
// MigrationType is the type of migration.
type MigrationType string
const (
TypeGo MigrationType = "go"
TypeSQL MigrationType = "sql"
)
// Source represents a single migration source.
//
// The Path field may be empty if the migration was registered manually. This is typically the case
// for Go migrations registered using the [WithGoMigration] option.
type Source struct {
Type MigrationType
Path string
Version int64
}
// MigrationResult is the result of a single migration operation.
type MigrationResult struct {
Source *Source
Duration time.Duration
Direction string
// Empty indicates no action was taken during the migration, but it was still versioned. For
// SQL, it means no statements; for Go, it's a nil function.
Empty bool
// Error is only set if the migration failed.
Error error
}
// State represents the state of a migration.
type State string
const (
// StatePending is a migration that exists on the filesystem, but not in the database.
StatePending State = "pending"
// StateApplied is a migration that has been applied to the database and exists on the
// filesystem.
StateApplied State = "applied"
// TODO(mf): we could also add a third state for untracked migrations. This would be useful for
// migrations that were manually applied to the database, but not versioned. Or the Source was
// deleted, but the migration still exists in the database. StateUntracked State = "untracked"
)
// MigrationStatus represents the status of a single migration.
type MigrationStatus struct {
Source *Source
State State
AppliedAt time.Time
}