migration

package
v0.0.0-...-94ea2d4 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(ctx context.Context, c chan *Result, to, from dbconn.DBConn)

Migrate initializes the EDB database for the IM Operands and performs any additional migrations that may be needed.

Types

type Migration

type Migration struct {
	Name         string        // name of the migration registered in the changelog
	ID           int           // integer used as a unique identifier for the migration
	To           dbconn.DBConn // connection to database where data is being moved to or transformed on
	From         dbconn.DBConn // connection to database where data is coming from
	Dependencies []*Migration  // migrations that must be performed before this one

	RunFunc *MigrationFunc // function containing migration logic
	// contains filtered or unexported fields
}

Migration represents some sort of transformation or transfer of data from one database to another.

func (*Migration) Run

func (m *Migration) Run(ctx context.Context) (err error)

type MigrationBuilder

type MigrationBuilder struct {
	Migration *Migration
}

func FromMigration

func FromMigration(m *Migration) *MigrationBuilder

func NewMigration

func NewMigration() *MigrationBuilder

func (*MigrationBuilder) Build

func (m *MigrationBuilder) Build() *Migration

func (*MigrationBuilder) Dependencies

func (m *MigrationBuilder) Dependencies(d []*Migration) *MigrationBuilder

func (*MigrationBuilder) From

func (*MigrationBuilder) ID

func (*MigrationBuilder) Name

func (m *MigrationBuilder) Name(name string) *MigrationBuilder

func (*MigrationBuilder) RunFunc

func (*MigrationBuilder) To

type MigrationFunc

type MigrationFunc func(context.Context, dbconn.DBConn, dbconn.DBConn) error

type MigrationQueue

type MigrationQueue []*Migration

MigrationQueue is a priority queue for Migrations. It pops off Migrations in decreasing order of priority. Implementation based upon example from documentation for container/heap.

func PlanMigrations

func PlanMigrations(ctx context.Context, to, from dbconn.DBConn) (mq *MigrationQueue, err error)

PlanMigrations produces a priority queue of Migrations to perform based upon the database connections that have been provided.

func (MigrationQueue) Len

func (mq MigrationQueue) Len() int

func (MigrationQueue) Less

func (mq MigrationQueue) Less(i, j int) bool

func (*MigrationQueue) Pop

func (mq *MigrationQueue) Pop() any

func (*MigrationQueue) Push

func (mq *MigrationQueue) Push(x any)

func (MigrationQueue) Swap

func (mq MigrationQueue) Swap(i, j int)

func (*MigrationQueue) UpdatePrioritiesByDependencyCount

func (mq *MigrationQueue) UpdatePrioritiesByDependencyCount()

UpdatePrioritiesByDependencyCount updates the priority values of Migrations in the MigrationQueue to 2^(h-1), where h is the max distance from another Migration in terms of dependencies. For example, consider the following chain of dependencies:

A <- depends - B <- depends - C <- depends - D

`A` would have a priority of 8 (2^3), `B` would have 4, `C` would have 2, and `D` would have 1.

A Migration that is childless and has no dependencies retains the default priority of 0.

type Result

type Result struct {
	Complete   []*Migration
	Incomplete []*Migration

	Error error
}

func (*Result) IsFailure

func (r *Result) IsFailure() bool

func (*Result) IsMarkedComplete

func (r *Result) IsMarkedComplete(m *Migration) bool

func (*Result) IsMarkedIncomplete

func (r *Result) IsMarkedIncomplete(m *Migration) bool

func (*Result) IsSuccess

func (r *Result) IsSuccess() bool

Jump to

Keyboard shortcuts

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