Documentation ¶
Index ¶
Constants ¶
View Source
const ( PathFieldName = "migrator.source" DriverReplacement = "${db.driver}" PathDefault = "file://./migrations/" + DriverReplacement )
Variables ¶
View Source
var Component = &app.Component{ Dependencies: app.Components{ table.Component, }, Constructor: func(container container.Container) error { return container.Provides( NewConfig, NewWithConfigurator, ) }, BindFlags: func(flagSet *pflag.FlagSet, container container.Container) error { return container.Invoke(func(config *Config) { flagSet.StringVar(&config.Path, PathFieldName, PathDefault, "path to migrations directory") }) }, Run: func(c container.Container) error { closer, err := container.Get[closer.Closer](c) if err != nil { return err } migrator, err := container.Get[*migrate.Migrate](c) if err != nil { return err } informer, err := container.Get[logger.Informer](c) if err != nil { return err } err = migrator.Up() if err != nil && err != migrate.ErrNoChange { return err } if err == migrate.ErrNoChange { return nil } version, _, err := migrator.Version() if err != nil { closer.Close() return err } informer.Infof("migrator: up to '%d' version", version) return nil }, }
Functions ¶
func NewWithConfigurator ¶
func NewWithConfigurator( config *Config, configurator configurator.Configurator, db client.DataBase, informer logger.Informer, tableReplacer table.Replacer, ) (*migrate.Migrate, error)
Types ¶
type Config ¶
type Config struct {
Path string
}
func Configuration ¶
func Configuration(config *Config, configurator configurator.Configurator) *Config
Click to show internal directories.
Click to hide internal directories.