Documentation
¶
Index ¶
- Constants
- Variables
- func List() []string
- func New(driver Driver, cfg Settings) database.Driver
- func Open(url string) (database.Driver, error)
- func Register(name string, driver Driver, cfg Settings)
- type Config
- func (m *Config) Close() error
- func (m *Config) Drop() error
- func (m *Config) Lock() error
- func (m *Config) Open(filePath string) (database.Driver, error)
- func (m *Config) Run(migration io.Reader) error
- func (m *Config) SetVersion(version int, dirty bool) error
- func (m *Config) Unlock() error
- func (m *Config) Version() (int, bool, error)
- type Driver
- type Settings
Constants ¶
const DefaultPerm fs.FileMode = 0666
DefaultPerm defines the default file permissions (0666) for created config files.
Variables ¶
var CommentSuffix = "______"
CommentSuffix defines the special suffix used to identify comment-like keys. Keys ending with this suffix will be treated as comments and converted to actual '#'(YAML) comments in output.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config represents the core struct used to manage config-based migrations. It contains a driver for reading/writing config data and a locked file to prevent concurrent access.
func (*Config) Drop ¶
Drop resets the config file by truncating it and writing empty/default content.
func (*Config) Run ¶
Run applies a migration by reading the migration data and merging it with existing config data.
func (*Config) SetVersion ¶
SetVersion updates the current config file with version and dirty (force) flags.
type Driver ¶
type Driver interface {
// Unmarshal — deserializes data from []byte into a map.
Unmarshal([]byte, interface{}) error
// Marshal — serializes a map into []byte.
Marshal(interface{}, bool) ([]byte, error)
// Version — extracts the version number from the data.
Version([]byte) (int, bool, error)
// EmptyData — returns the default empty data content.
EmptyData() []byte
}
Driver is the interface that every config driver must implement.
type Settings ¶
type Settings struct {
// Path — the path to the configuration file.
Path string
// Perm — file permissions for reading/writing the config file.
Perm fs.FileMode
// UnableToReplaceComments True if some comments could be replaced
UnableToReplaceComments bool
}
Settings represents the configuration settings for a config driver.