migrator

package
v0.11.3 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 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, opts ...Option) (*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, tableSchema 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)

type Option added in v0.8.4

type Option func(*Migrator)

Jump to

Keyboard shortcuts

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