handler

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package handler includes handling migration executions related logic, and it can be used by client code that acts as user entrypoint (for example CLI entrypoint).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecutedMigration

type ExecutedMigration struct {
	Migration migration.Migration
	Execution *execution.MigrationExecution
}

ExecutedMigration Value object that groups information related to a migration execution

type ExecutionPlan

type ExecutionPlan struct {
	// contains filtered or unexported fields
}

ExecutionPlan Entity which decides what can be migrated. Helpful for seeing the current migrations & executions state

func NewPlan

func NewPlan(
	registry migration.MigrationsRegistry,
	repository execution.Repository,
) (*ExecutionPlan, error)

NewPlan Creates a new ExecutionPlan. Errors if it finds that migrations and executions loaded from the provided registry & repository are in an inconsistent state. An inconsistent state can be: more executions in the repository than the total number of registered migrations

func (*ExecutionPlan) AllExecuted

func (plan *ExecutionPlan) AllExecuted() []ExecutedMigration

func (*ExecutionPlan) AllToBeExecuted

func (plan *ExecutionPlan) AllToBeExecuted() []migration.Migration

func (*ExecutionPlan) FinishedExecutionsCount

func (plan *ExecutionPlan) FinishedExecutionsCount() int

func (*ExecutionPlan) LastExecuted

func (plan *ExecutionPlan) LastExecuted() ExecutedMigration

func (*ExecutionPlan) NextToExecute

func (plan *ExecutionPlan) NextToExecute() migration.Migration

func (*ExecutionPlan) RegisteredMigrationsCount

func (plan *ExecutionPlan) RegisteredMigrationsCount() int

type ExecutionPlanBuilder

type ExecutionPlanBuilder func(
	registry migration.MigrationsRegistry,
	repository execution.Repository,
) (*ExecutionPlan, error)

type MigrationsHandler

type MigrationsHandler struct {
	// contains filtered or unexported fields
}

MigrationsHandler A service which handles all migration related requests. Core service which should include all behaviour related to running the migrations

func NewHandler

func NewHandler(
	registry migration.MigrationsRegistry,
	repository execution.Repository,
	newExecutionPlan ExecutionPlanBuilder,
) (*MigrationsHandler, error)

func (*MigrationsHandler) ForceDown

func (handler *MigrationsHandler) ForceDown(version uint64) (ExecutedMigration, error)

func (*MigrationsHandler) ForceUp

func (handler *MigrationsHandler) ForceUp(version uint64) (ExecutedMigration, error)

func (*MigrationsHandler) MigrateDown

func (handler *MigrationsHandler) MigrateDown(numOfRuns NumOfRuns) ([]ExecutedMigration, error)

func (*MigrationsHandler) MigrateUp

func (handler *MigrationsHandler) MigrateUp(numOfRuns NumOfRuns) ([]ExecutedMigration, error)

type NumOfRuns

type NumOfRuns int

NumOfRuns Type which is used to process the allowed user input for specifying the number of migrations to run

func NewNumOfRuns

func NewNumOfRuns(num string) (NumOfRuns, error)

Jump to

Keyboard shortcuts

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