Documentation
¶
Overview ¶
Package migration allows to perform versioned migrations in your ArangoDB.
Index ¶
- Constants
- Variables
- func DBCollectionNameAttr(name string) attribute.KeyValue
- func DBSystemAttr() attribute.KeyValue
- func HasVersion(migrations []Migration, version uint) bool
- func MigrateIndexes(ctx context.Context, col arangoDriver.Collection, indexes []IndexParam) error
- func MigrationCurrentVersionAttr(v uint) attribute.KeyValue
- func MigrationDescriptionAttr(desc string) attribute.KeyValue
- func MigrationDirectionDownAttr() attribute.KeyValue
- func MigrationDirectionUpAttr() attribute.KeyValue
- func MigrationDryRunAttr(dryRun bool) attribute.KeyValue
- func MigrationLatestVersionAttr(v uint) attribute.KeyValue
- func MigrationResolvedTargetVersionAttr(v uint) attribute.KeyValue
- func MigrationTargetVersionAttr(v int) attribute.KeyValue
- func MigrationVersionAttr(v uint) attribute.KeyValue
- func PackageAttr(pkg string) attribute.KeyValue
- type CollectionParam
- type EdgeCollectionParam
- type GraphParam
- type IndexParam
- type IndexType
- type Migration
- type MigrationFunc
- type Migrations
- type Migrator
- func (m *Migrator) Down(ctx context.Context, targetVersion int) (outErr error)
- func (m *Migrator) SetMigrationsCollection(name string)
- func (m *Migrator) Up(ctx context.Context, targetVersion int) (outErr error)
- func (m *Migrator) Version(ctx context.Context) (current uint, latest uint, desc string, outErr error)
- type NewMigratorOptions
- type ViewParam
Constants ¶
const AllAvailable = -1
AllAvailable used in "Up" or "Down" methods to run all available migrations.
const DefaultMigrationsCollection = "migrations"
Variables ¶
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 DBCollectionNameAttr ¶ added in v0.0.148
DBCollectionNameAttr returns an attribute for the database collection name.
func DBSystemAttr ¶ added in v0.0.148
DBSystemAttr returns an attribute identifying the database system.
func HasVersion ¶
func MigrateIndexes ¶ added in v0.0.19
func MigrateIndexes(ctx context.Context, col arangoDriver.Collection, indexes []IndexParam) error
func MigrationCurrentVersionAttr ¶ added in v0.0.148
MigrationCurrentVersionAttr returns an attribute for the current applied migration version. Migration version numbers are far below math.MaxInt, so the uint->int conversion is safe.
func MigrationDescriptionAttr ¶ added in v0.0.148
MigrationDescriptionAttr returns an attribute for an individual migration's description.
func MigrationDirectionDownAttr ¶ added in v0.0.148
MigrationDirectionDownAttr returns an attribute marking a downward migration direction.
func MigrationDirectionUpAttr ¶ added in v0.0.148
MigrationDirectionUpAttr returns an attribute marking an upward migration direction.
func MigrationDryRunAttr ¶ added in v0.0.148
MigrationDryRunAttr returns an attribute indicating whether the migration is a dry-run.
func MigrationLatestVersionAttr ¶ added in v0.0.148
MigrationLatestVersionAttr returns an attribute for the latest known migration version.
func MigrationResolvedTargetVersionAttr ¶ added in v0.0.148
MigrationResolvedTargetVersionAttr returns an attribute for the clamped resolved target version.
func MigrationTargetVersionAttr ¶ added in v0.0.148
MigrationTargetVersionAttr returns an attribute for the requested target migration version.
func MigrationVersionAttr ¶ added in v0.0.148
MigrationVersionAttr returns an attribute for an individual migration's version number.
func PackageAttr ¶ added in v0.0.148
PackageAttr returns an attribute for the migration package name.
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
}
type GraphParam ¶ added in v0.0.19
type GraphParam struct {
Name string
Options *arangoDriver.CreateGraphOptions
VertexCollections []string
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
func ParseIndexType ¶ added in v0.0.19
func (IndexType) MarshalJSON ¶ added in v0.0.19
func (*IndexType) UnmarshalJSON ¶ added in v0.0.19
type Migration ¶
type Migration struct {
Version uint
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 Migrations ¶ added in v0.0.50
type Migrations []Migration
func (Migrations) Sort ¶ added in v0.0.50
func (m Migrations) Sort()
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 ¶
Down performs "down" migration to bring back migrations to `version`. If targetVersion<=0 all "down" migrations will be performed. If targetVersion>0, only the down migrations where version>targetVersion will be performed (only if they were applied).
func (*Migrator) SetMigrationsCollection ¶
SetMigrationsCollection replaces name of collection for storing migration information. By default it is "migrations".
type NewMigratorOptions ¶ added in v0.0.17
type NewMigratorOptions struct {
Database arangoDriver.Database
Package string
Migrations Migrations
DryRun bool
Logger *loggerx.Logger
Tracer *otelx.Tracer
}
type ViewParam ¶ added in v0.0.19
type ViewParam struct {
Name string
Options *arangoDriver.ArangoSearchViewProperties
}