-
Notifications
You must be signed in to change notification settings - Fork 0
/
gomig.go
32 lines (27 loc) · 898 Bytes
/
gomig.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
// Package gomig TODO: add documentation
package gomig
import (
"context"
"errors"
)
var backend BackendAdapter
var (
// ErrNoBackend returned by runners if no BackendAdapter set
ErrNoBackend = errors.New("NO_BACKEND")
// ErrNoMigrations returns by NewRunner if no migrations provided
ErrNoMigrations = errors.New("NO_MIGRATIONS")
// ErrMigrationFailed returned by runners if migration was failed
ErrMigrationFailed = errors.New("MIGRATION_FAILED")
)
// Migration TODO: Add documentation
type Migration interface {
Up(ctx context.Context) (messages []string, err error)
Down(ctx context.Context) (messages []string, err error)
Name() string
}
// BackendAdapter TODO: Add documentation
type BackendAdapter interface {
GetVersion(ctx context.Context) (uint, error)
SaveVersion(ctx context.Context, ver uint, name string, messages []string) error
Reset(ctx context.Context) error
}