Documentation
¶
Index ¶
- Constants
- type Error
- type Migrator
- func (m *Migrator) Down(client *kivik.Client, dbPrefix string) (oldVersion int64, newVersion int64, err error)
- func (m *Migrator) Init(client *kivik.Client, dbPrefix string) (oldVersion int64, newVersion int64, err error)
- func (m *Migrator) Reset(client *kivik.Client, dbPrefix string) (oldVersion int64, newVersion int64, err error)
- func (m *Migrator) Run(dbPrefix string, args ...string) (oldVersion int64, newVersion int64, err error)
- func (m *Migrator) SetVersion(client *kivik.Client, dbPrefix string, target int64) (oldVersion int64, newVersion int64, err error)
- func (m *Migrator) Up(client *kivik.Client, dbPrefix string, target int64) (oldVersion int64, newVersion int64, err error)
- func (m *Migrator) Version(client *kivik.Client, dbPrefix string) (oldVersion int64, newVersion int64, err error)
Constants ¶
const ErrorCommandRequired = Error("Command required")
ErrorCommandRequired means that no command was specified.
const ErrorInvalidVersionArgumentFormat = Error("Invalid version argument format")
ErrorInvalidVersionArgumentFormat means that the format of an argument named `version` does not correspond to int64.
const ErrorMigrationsAreNotInitialized = Error("Migrations are not initialized, try to call `init` at first")
ErrorMigrationsAreNotInitialized means that migrations database is empty.
const ErrorMigrationsDatabaseAlreadyExists = Error("Migrations database already exists")
ErrorMigrationsDatabaseAlreadyExists means that `migrations` database already exists.
const ErrorNoMigrations = Error("No migrations")
ErrorNoMigrations means that no migrations ware found at the specified path.
const ErrorSomeMigrationsAreAbsent = Error("Some migrations are absent")
ErrorSomeMigrationsAreAbsent means that some migrations files are absent.
const ErrorTargetVersionNotFound = Error("Target migration version was not found")
ErrorTargetVersionNotFound means that the target migration version was not found in migrations list.
const ErrorUnequalCountsOfMigrations = Error("Unequal counts of `up` and `down` migrations")
ErrorUnequalCountsOfMigrations means that the count of `up` migrations is not equal to the count of `down` migrations.
const ErrorUnexpectedCommand = Error("Unexpected command")
ErrorUnexpectedCommand means that command name is unknown.
const ErrorVersionNumberRequired = Error("Version number required")
ErrorVersionNumberRequired means that no version number was specified via command line.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
Migrator declares MongoDB migrations manager.
func NewMigrator ¶
NewMigrator returns a new instance of `Migrator`.
func (*Migrator) Down ¶
func (m *Migrator) Down(client *kivik.Client, dbPrefix string) (oldVersion int64, newVersion int64, err error)
Down downgrades database revision to the previous version.
func (*Migrator) Init ¶
func (m *Migrator) Init(client *kivik.Client, dbPrefix string) (oldVersion int64, newVersion int64, err error)
Init creates `migrations` collection if it does not exist and records the initial zero-migration.
func (*Migrator) Reset ¶
func (m *Migrator) Reset(client *kivik.Client, dbPrefix string) (oldVersion int64, newVersion int64, err error)
Reset resets database to the zero-revision.
func (*Migrator) Run ¶
func (m *Migrator) Run(dbPrefix string, args ...string) (oldVersion int64, newVersion int64, err error)
Run interprets commands.
func (*Migrator) SetVersion ¶
func (m *Migrator) SetVersion(client *kivik.Client, dbPrefix string, target int64) (oldVersion int64, newVersion int64, err error)
SetVersion forces database revisiton version.