arangox

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package migration allows to perform versioned migrations in your ArangoDB.

Index

Constants

View Source
const AllAvailable = -1

AllAvailable used in "Up" or "Down" methods to run all available migrations.

Variables

This section is empty.

Functions

func HasVersion

func HasVersion(migrations []Migration, version uint64) bool

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(ctx context.Context, 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

func (m *Migrator) Down(ctx context.Context, n int) error

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

func (m *Migrator) SetMigrationsCollection(name string)

SetMigrationsCollection replaces name of collection for storing migration information. By default it is "migrations".

func (*Migrator) SetVersion

func (m *Migrator) SetVersion(version uint64, description string) error

SetVersion forcibly changes database version to provided.

func (*Migrator) Up

func (m *Migrator) Up(ctx context.Context, n int) error

Up performs "up" migrations to latest available version. If n<=0 all "up" migrations with newer versions will be performed. If n>0 only n migrations with newer version will be performed.

func (*Migrator) Version

func (m *Migrator) Version(ctx context.Context) (uint64, string, error)

Version returns current database version and comment.

Jump to

Keyboard shortcuts

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