arangox

package
v0.0.43 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 8 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

View Source
var (
	IndexType_name = map[int]string{
		0: "PERSISTENT",
		1: "GEO",
		2: "HASH",
		3: "INVERTED",
		4: "TIME_TO_LIVE",
		5: "ZKD",
		6: "SKIP_LIST",
	}
	IndexType_value = map[string]int{
		"PERSISTENT":   0,
		"GEO":          1,
		"HASH":         2,
		"INVERTED":     3,
		"TIME_TO_LIVE": 4,
		"ZKD":          5,
		"SKIP_LIST":    6,
	}
)

Functions

func HasVersion

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

func MigrateIndexes added in v0.0.19

func MigrateIndexes(ctx context.Context, col arangoDriver.Collection, indexes []IndexParam) error

Types

type CollectionParam added in v0.0.19

type CollectionParam struct {
	Name    string
	Options *arangoDriver.CreateCollectionOptions
	Indexes []IndexParam
}

type EdgeCollectionParam added in v0.0.19

type EdgeCollectionParam struct {
	Name         string
	Constraints  arangoDriver.VertexConstraints
	Indexes      []IndexParam
	CreateFromDb bool
}

type GraphParam added in v0.0.19

type GraphParam struct {
	Name              string
	Options           *arangoDriver.CreateGraphOptions
	VertexCollections []CollectionParam

	EdgeCollections []EdgeCollectionParam
}

type IndexParam added in v0.0.19

type IndexParam struct {
	Type                   IndexType
	Fields                 []string
	ExpireAfter            int
	InvertedIndexOptions   *arangoDriver.InvertedIndexOptions
	ZKDIndexOptions        *arangoDriver.EnsureZKDIndexOptions
	SkipListIndexOptions   *arangoDriver.EnsureSkipListIndexOptions
	PersistentIndexOptions *arangoDriver.EnsurePersistentIndexOptions
	HashIndexOptions       *arangoDriver.EnsureHashIndexOptions
	GeoIndexOptions        *arangoDriver.EnsureGeoIndexOptions
	TTLIndexOptions        *arangoDriver.EnsureTTLIndexOptions
}

type IndexType added in v0.0.19

type IndexType int
const (
	IndexTypePersistent IndexType = iota
	IndexTypeGeo
	IndexTypeHash
	IndexTypeInverted
	IndexTypeTTL
	IndexTypeZKD
	IndexTypeSkipList
)

func ParseIndexType added in v0.0.19

func ParseIndexType(s string) (IndexType, error)

func (IndexType) MarshalJSON added in v0.0.19

func (u IndexType) MarshalJSON() ([]byte, error)

func (IndexType) String added in v0.0.19

func (u IndexType) String() string

func (*IndexType) UnmarshalJSON added in v0.0.19

func (u *IndexType) UnmarshalJSON(data []byte) (err error)

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(in NewMigratorOptions) *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) 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.

type NewMigratorOptions added in v0.0.17

type NewMigratorOptions struct {
	Database   arangoDriver.Database
	Package    string
	Migrations []Migration
}

type ViewParam added in v0.0.19

type ViewParam struct {
	Name    string
	Options *arangoDriver.ArangoSearchViewProperties
}

Jump to

Keyboard shortcuts

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