-
Notifications
You must be signed in to change notification settings - Fork 5
/
config.go
55 lines (48 loc) · 2.81 KB
/
config.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 libschema
// OverrideOptions define the command line flags and/or configuration block that can be
// provided to control libschema's behavior. OverrideOptions is designed to be filled
// with https://github.com/muir/nfigure but it doesn't have to be done that way.
type OverrideOptions struct {
// MigrateOnly causes program to exit when migrations are complete.
// Asynchronous migrations will be skipped. If no migrations are need,
// the program will exit very quickly. This is accomplished with a call
// to os.Exit().
MigrateOnly bool `flag:"migrate-only" help:"Call os.Exit() after completing migrations"`
// MigrateDatabase specifies that only a specific database should
// be migrated. The name must match to a name provided with the schema.NewDatabase() call.
// For both libschema/lsmysql and libschema/lspostgres, that is the name parameter to
// New() NOT the database name in the DSN. This is a logical name.
MigrateDatabase string `flag:"migrate-database" help:"Migrate only the this database"`
// MigrateDSN overrides the data source name for a single database. It must be used in
// conjunction with MigrateDatabase unless there are only migrations for a single database.
MigrateDSN string `flag:"migrate-dsn" help:"Override *sql.DB, must combine with --migrate-database"`
// NoMigrate command line flag / config variable skips all migrations
NoMigrate bool `flag:"no-migrate" help:"Skip all migrations (except async)"`
// ErrorIfMigrateNeeded command line flag / config variable causes Migrate() to return error if there are
// migrations required. Asynchronous migrations do not count as required and will
// run in the background.
// In combination with EverythingSynchronous = true, if there are asychronous migrations pending then
// Migrate() will return error immediately.
ErrorIfMigrateNeeded bool `flag:"error-if-migrate-needed" help:"Return error if migrations are not current"`
// EverythingSynchronous command line flag / config variable causes asynchronous migrations to be
// treated like regular migrations from the point of view of --migrate-only, --no-migrate,
// and --error-if-migrate-needed.
EverythingSynchronous bool `flag:"migrate-all-synchronously" help:"Run async migrations synchronously"`
}
// DefaultOverrides provides default values for Options.Overrides. DefaultOverrides
// is only used when Options.Overrides is nil.
//
// DefaultOverrides can be filled by nfigure:
//
// import "github.com/muir/nfigure"
// registry := nfigure.NewRegistry()
// request, err := registry.Request(&libschema.DefaultOverrides)
// err := registry.Configure()
//
// DefaultOverrides can be filled using the "flag" package:
//
// import "flag"
// import "github.com/muir/nfigure"
// nfigure.MustExportToFlagSet(flag.CommandLine, "flag", &libschema.DefautOverrides)
//
var DefaultOverrides OverrideOptions