-
Notifications
You must be signed in to change notification settings - Fork 0
/
manager_options.go
58 lines (50 loc) · 1.31 KB
/
manager_options.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
56
57
58
package golembic
import (
"database/sql"
)
// OptManagerMetadataTable sets the metadata table name on a manager.
func OptManagerMetadataTable(table string) ManagerOption {
return func(m *Manager) error {
m.MetadataTable = table
return nil
}
}
// OptManagerConnectionPool sets the connection pool on a manager.
func OptManagerConnectionPool(pool *sql.DB) ManagerOption {
return func(m *Manager) error {
m.ConnectionPool = pool
return nil
}
}
// OptManagerProvider sets the provider on a manager.
func OptManagerProvider(provider EngineProvider) ManagerOption {
return func(m *Manager) error {
m.Provider = provider
return nil
}
}
// OptManagerSequence sets the migrations sequence on a manager.
func OptManagerSequence(migrations *Migrations) ManagerOption {
return func(m *Manager) error {
m.Sequence = migrations
return nil
}
}
// OptManagerLog sets the logger interface on a manager. If `log` is `nil`
// the option will return an error.
func OptManagerLog(log PrintfReceiver) ManagerOption {
return func(m *Manager) error {
if log == nil {
return ErrNilInterface
}
m.Log = log
return nil
}
}
// OptDevelopmentMode sets the development mode flag on a manager.
func OptDevelopmentMode(mode bool) ManagerOption {
return func(m *Manager) error {
m.DevelopmentMode = mode
return nil
}
}