migrator

package
v1.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MigrationCollection = "_migration"
	ErrFileAccess       = 0x1
	ErrDbAccess         = 0x2
	ErrDbOperation      = 0x4
	ErrOrderFailed      = 0x8
	ErrHashingFailed    = 0x16
)

Variables

This section is empty.

Functions

func SetLogger added in v1.0.3

func SetLogger(logger log.ILogger)

Types

type MigrationError

type MigrationError struct {
	Message string
	Code    int
}

func Migrate

func Migrate(dataDir string, db mgo.IDatabase, failOnOrderMismatch bool, collectionIdSuffix ...string) *MigrationError

Migrate begins a DB migration process by migrating the scripts located in the provided data dir and storing the migration track in a migration repository ('_migration' by default)

{dataDir}              - The location where the migration scripts are contained
{db}                   - The database client already initialized
{failOnOrderMismatch}  - Indicates whether the migration should fail if the order of previously migrated scripts
                         have failed (removing or adding scripts between previously migrated scripts)
{collectionIdSuffix}   - (optional) A suffix to use for the collection name where the migration data is stored.
                         This is useful when sharing the same database instance with multiple services that own
                         their unique collections.

func (*MigrationError) Error

func (m *MigrationError) Error() string

Returns the error message

func (*MigrationError) ErrorCode

func (m *MigrationError) ErrorCode() int

func (*MigrationError) Is

func (m *MigrationError) Is(errorCode int) bool

type MigrationErrorCode

type MigrationErrorCode int

type MigrationInfo

type MigrationInfo struct {
	ScriptId  string    `json:"script_id" bson:"script_id"`
	Hash      string    `json:"hash" bson:"hash"`
	Timestamp time.Time `json:"timestamp" bson:"timestamp"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL