migrator

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: MPL-2.0 Imports: 19 Imported by: 2

Documentation

Index

Constants

View Source
const (
	Latest  = "latest"
	Initial = "initial"
	Down    = "down_testing" // used in testing

)

Variables

This section is empty.

Functions

func ReadMigrationFiles

func ReadMigrationFiles(log hclog.Logger, migrationFiles embed.FS) (map[string]map[string][]byte, error)

ReadMigrationFiles reads the given embed.FS for the migration files and returns a map of dialect directories vs. filenames vs. data

Types

type Migrator

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

func New

func New(log hclog.Logger, dt schema.DialectType, migrationFiles map[string]map[string][]byte, dsnURI, providerName string, postHook func(context.Context) error) (*Migrator, error)

func (*Migrator) Close

func (m *Migrator) Close() error

func (*Migrator) DowngradeProvider

func (m *Migrator) DowngradeProvider(version string) (retErr error)

func (*Migrator) DropProvider

func (m *Migrator) DropProvider(ctx context.Context, schema map[string]*schema.Table) (retErr error)

func (*Migrator) FindLatestMigration

func (m *Migrator) FindLatestMigration(requestedVersion string) (uint, error)

FindLatestMigration finds closet migration to the requested version

For example we have the following migrations:
1_001, 2_005, 3_009

if we ask for 007 we get 005 if we ask for 004 we get 001 if we ask for 005 we get 005

func (*Migrator) SetVersion

func (m *Migrator) SetVersion(requestedVersion string) (retErr error)

func (*Migrator) UpgradeProvider

func (m *Migrator) UpgradeProvider(version string) (retErr error)

func (*Migrator) Version

func (m *Migrator) Version() (string, bool, error)

Jump to

Keyboard shortcuts

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