migration

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContainerID defines the id to be used as the container registration id
	// of a migrator instance, and as a base id of all other migration
	// package instances registered in the application container.
	ContainerID = rest.ContainerID + ".migration"

	// ContainerMigrationTag defines the default tag to be used to identify
	// a migration entry in the container.
	ContainerMigrationTag = ContainerID + ".migration"
)
View Source
const (
	// Env defines the gapp-rest/migration package environment entry id
	// base string.
	Env = rest.Env + "_MIGRATION"

	// EnvContainerDatabaseID defines the name of the environment variable
	// to be checked for an overriding value for the migration dao assigned
	// db interface instance.
	EnvContainerDatabaseID = Env + "_CONTAINER_DATABASE_ID"

	// EnvAutoMigrate defines the name of the environment variable
	// to be checked if an automatic migration should be executed at boot.
	EnvAutoMigrate = Env + "_AUTO_MIGRATE"
)

Variables

View Source
var (
	// ContainerDatabaseID defines the default container id to be used when
	// retrieving the migration db connection.
	ContainerDatabaseID = db.ContainerPrimaryID

	// AutoMigrate defines the flag that will be used to enable the auto
	// migration on application boot.
	AutoMigrate = true
)

Functions

func NewProvider

func NewProvider() gapp.Provider

NewProvider will create a new migration provider instance

Types

type Dao added in v1.5.0

type Dao interface {
	Last() model
	Up(rec model) model
}

Dao defines an interface to the migration DAO instance responsible to manager the installed migrations.

func NewDao added in v1.5.0

func NewDao(db *gorm.DB) (Dao, error)

NewDao instantiates a new migration DAO instance.

type Migration

type Migration interface {
	Version() uint
	Migrate() error
}

Migration defines an interface that all migrations must obey.

type Migrator

type Migrator interface {
	AddMigration(migration Migration) error
	Migrate() error
}

Migrator defines the interface of an application persistence layer migration manager.

func NewMigrator added in v1.5.0

func NewMigrator(dao Dao) Migrator

NewMigrator instantiates a new migration manager instance.

Jump to

Keyboard shortcuts

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