Documentation ¶
Overview ¶
Package migration allows to perform versioned migrations in your ArangoDB.
Index ¶
- Constants
- func HasVersion(migrations []Migration, version uint64) bool
- type Migration
- type MigrationFunc
- type Migrator
- func (m *Migrator) Down(ctx context.Context, n int) error
- func (m *Migrator) SetMigrationsCollection(name string)
- func (m *Migrator) SetVersion(version uint64, description string) error
- func (m *Migrator) Up(ctx context.Context, n int) error
- func (m *Migrator) Version(ctx context.Context) (uint64, string, error)
Constants ¶
const AllAvailable = -1
AllAvailable used in "Up" or "Down" methods to run all available migrations.
Variables ¶
This section is empty.
Functions ¶
func HasVersion ¶
Types ¶
type Migration ¶
type Migration struct { Version uint64 Description string Up MigrationFunc Down MigrationFunc }
Migration represents single database migration. Migration contains:
- version: migration version, must be unique in migration list
- description: text description of migration
- up: callback which will be called in "up" migration process
- down: callback which will be called in "down" migration process for reverting changes
type MigrationFunc ¶
type MigrationFunc func(db arangoDriver.Database) error
MigrationFunc is used to define actions to be performed for a migration.
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
Migrate is type for performing migrations in provided database. Database versioned using dedicated collection. Each migration applying ("up" and "down") adds new document to collection. This document consists migration version, migration description and timestamp. Current database version determined as version in latest added document (biggest "_key") from collection mentioned above.
func NewMigrator ¶
func NewMigrator(db arangoDriver.Database, migrations ...Migration) *Migrator
func (*Migrator) Down ¶
Down performs "down" migration to oldest available version. If n<=0 all "down" migrations with older version will be performed. If n>0 only n migrations with older version will be performed.
func (*Migrator) SetMigrationsCollection ¶
SetMigrationsCollection replaces name of collection for storing migration information. By default it is "migrations".
func (*Migrator) SetVersion ¶
SetVersion forcibly changes database version to provided.