Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseMigrator ¶
BaseMigrator is the base migrator for control flow.
type DbPlugin ¶
type DbPlugin interface {
Connect(ctx context.Context) error
GetSchema(ctx context.Context, version string) (Schema, error)
ApplyMigration(ctx context.Context, mi Migration) error
RevertMigration(ctx context.Context, mi Migration) error
}
DbPlugin is the interface for the plugin
type Gomiger ¶
type Gomiger interface {
Up(ctx context.Context, toVersion string) error
Down(ctx context.Context, atVersion string) error
Connect(ctx context.Context) error
}
Gomiger is the interface for the migrator
type GomigerConfig ¶
type GomigerConfig struct {
// Path to the migration root folder.
Path string `yaml:"path"`
// The package name of the migrator & migrations.
// Default by the folder name of the path.
PkgName string `yaml:"pkg_name"`
// Database connection string.
URI string `yaml:"uri"`
// The path to the table / collection schema store.
SchemaStore string `yaml:"schema_store"`
}
GomigerConfig is the global migration module configuration.
func GetGomigerRC ¶
func GetGomigerRC(rcPath string) (*GomigerConfig, error)
GetGomigerRC returns the global migration module configuration
func (*GomigerConfig) ParseYAML ¶
func (rc *GomigerConfig) ParseYAML(path string) error
ParseYAML parse the RC file in YAML format.
func (*GomigerConfig) PopulateAndValidate ¶
func (rc *GomigerConfig) PopulateAndValidate() error
PopulateAndValidate populate data and validate it.
type Migration ¶
type Migration struct {
Version string
Up MutationFunc
Down MutationFunc
}
Migration contain a version name and a mutation function.
type MutationFunc ¶
MutationFunc is a function that applies a migration.
type Schema ¶
type Schema struct {
Version string `json:"version" bson:"version" validate:"required"`
Timestamp time.Time `json:"timestamp" bson:"timestamp" validate:"required"`
Status SchemaStatus `json:"status" bson:"status" validate:"required"`
}
Schema is a log for migrations
type SchemaStatus ¶
type SchemaStatus string
SchemaStatus is the status of the schema
var ( // InProgress is for a running migration InProgress SchemaStatus = "in_progress" // Dirty is for a failed migration Dirty SchemaStatus = "dirty" // Applied is for a completed migration Applied SchemaStatus = "applied" )
Click to show internal directories.
Click to hide internal directories.