migrate

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMigrationConfigMissing = errors.New("migration configuration is missing")

Functions

func SetDefaultConfigValues

func SetDefaultConfigValues(config *Config)

SetDefaultConfigValues sets default values for Config fields if they are not set.

Types

type Config

type Config struct {
	Driver          string
	DatabaseName    string
	DataSourceName  string
	PathMigration   string
	Scheme          string
	Table           string
	ConnMaxLifetime time.Duration
}

Config is registry configuration item.

type Migrate

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

func NewWithConfig

func NewWithConfig(config Config) (*Migrate, error)

NewWithConfig creates a new instance of Migrate using the provided Config.

func (*Migrate) Down

func (m *Migrate) Down(ctx context.Context, max int) error

Down reverts a specified number of migrations.

func (*Migrate) Up

func (m *Migrate) Up(ctx context.Context) error

Up applies all available migrations.

type SQLMigrator

type SQLMigrator interface {
	Up(ctx context.Context) error
	Down(ctx context.Context, max int) error
}

SQLMigrator works with migrations

func NewWithViper

func NewWithViper(cfg *viper.Viper) (SQLMigrator, error)

NewWithViper creates a new instance of a migration.

Jump to

Keyboard shortcuts

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