package mongodb

import "github.com/golang-migrate/migrate/v4/database/mongodb"

Index

Constants

const DefaultAdvisoryLockingFlag = true // the default value for the advisory locking feature flag. Default is true.
const DefaultLockTimeout = 15 // the default maximum time to wait for a lock to be released.
const DefaultLockTimeoutInterval = 10 // the default maximum intervals time for the locking timout.
const DefaultLockingCollection = "migrate_advisory_lock" // the collection to use for advisory locking by default.
const LockIndexName = "lock_unique_key" // the name of the index which adds unique constraint to the locking_key field.

Variables

var (
	ErrNoDatabaseName            = fmt.Errorf("no database name")
	ErrNilConfig                 = fmt.Errorf("no config")
	ErrLockTimeoutConfigConflict = fmt.Errorf("both x-advisory-lock-timeout-interval and x-advisory-lock-timout-interval were specified")
)
var DefaultMigrationsCollection = "schema_migrations"

Functions

func WithInstance

func WithInstance(instance *mongo.Client, config *Config) (database.Driver, error)

Types

type Config

type Config struct {
	DatabaseName         string
	MigrationsCollection string
	TransactionMode      bool
	Locking              Locking
}

type Locking

type Locking struct {
	CollectionName string
	Timeout        int
	Enabled        bool
	Interval       int
}

type Mongo

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

func (*Mongo) Close

func (m *Mongo) Close() error

func (*Mongo) Drop

func (m *Mongo) Drop() error

func (*Mongo) Lock

func (m *Mongo) Lock() error

Utilizes advisory locking on the config.LockingCollection collection This uses a unique index on the `locking_key` field.

func (*Mongo) Open

func (m *Mongo) Open(dsn string) (database.Driver, error)

func (*Mongo) Run

func (m *Mongo) Run(migration io.Reader) error

func (*Mongo) SetVersion

func (m *Mongo) SetVersion(version int, dirty bool) error

func (*Mongo) Unlock

func (m *Mongo) Unlock() error

func (*Mongo) Version

func (m *Mongo) Version() (version int, dirty bool, err error)

Source Files

mongodb.go

Version
v4.18.2 (latest)
Published
Jan 27, 2025
Platform
js/wasm
Imports
15 packages
Last checked
1 week ago

Tools for package owners.