migrationsmongo

package module
v0.0.0-...-829623a Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: MIT Imports: 9 Imported by: 0

README

migrations-mongo

This package implements the capability of migrating MongoDB databases.

Please check out the provided example.

Documentation

Index

Constants

View Source
const DefaultMigrationsCollectionName = "_migrations"

DefaultMigrationsCollectionName is the default collection name to be used to store the migrations.

Variables

View Source
var (
	ErrMissingSource = errors.New("source is required")
	ErrLockTimeout   = errors.New("timeout while trying to lock the database")
)
View Source
var (
	// DefaultLockTimeout is the default timeout to be used when trying to lock the database.
	DefaultLockTimeout = 10 * time.Second
)
View Source
var (
	// DefaultOperationTimeout is the default timeout to be used when performing operations in the database. Eg; Add the
	// migration document to the collection.
	DefaultOperationTimeout = 10 * time.Second
)

Functions

This section is empty.

Types

type Option

type Option func(target *Target) error

func CollectionName

func CollectionName(collectionName string) Option

CollectionName sets the collection name to be used to store the migrations. The default value is stored in the global variable DefaultMigrationsCollectionName.

func LockTimeout

func LockTimeout(timeout time.Duration) Option

LockTimeout sets the timeout to be used when trying to lock the database. The default value is read from DefaultLockTimeout.

func OperationTimeout

func OperationTimeout(timeout time.Duration) Option

OperationTimeout sets the timeout to be used when performing operations in the database. The default value is read from DefaultOperationTimeout.

type Target

type Target struct {
	// contains filtered or unexported fields
}

func NewTarget

func NewTarget(source migrations.Source, db *mongo.Database, options ...Option) (*Target, error)

func (*Target) Add

func (t *Target) Add(migration migrations.Migration) error

func (*Target) Create

func (t *Target) Create() error

func (*Target) Current

func (t *Target) Current() (migrations.Migration, error)

func (*Target) Destroy

func (t *Target) Destroy() error

func (*Target) Done

func (t *Target) Done() ([]migrations.Migration, error)

func (*Target) Lock

func (t *Target) Lock() (migrations.Unlocker, error)

func (*Target) Remove

func (t *Target) Remove(migration migrations.Migration) error

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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