-
Notifications
You must be signed in to change notification settings - Fork 4
/
migration_options.go
32 lines (26 loc) · 786 Bytes
/
migration_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
package gloat
import (
"bytes"
"encoding/json"
)
// MigrationOptions are the options for a migration. Keep in mind that some
// options (transaction) are not supported by every RDBMS (ahem, MySQL).
type MigrationOptions struct {
Transaction bool `json:"transaction"`
}
// DefaultMigrationOptions generate the default migration options.
//
// By default, the migrations are run in transaction, you can optionally
// configure them not to. For now, that is. 😅
func DefaultMigrationOptions() MigrationOptions {
return MigrationOptions{
Transaction: true,
}
}
func parseMigrationOptions(data []byte) (options MigrationOptions, err error) {
if data == nil {
return DefaultMigrationOptions(), nil
}
err = json.NewDecoder(bytes.NewReader(data)).Decode(&options)
return
}