migrator

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2023 License: MIT Imports: 7 Imported by: 0

README

sqlite-migrator

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultIDFunc

func DefaultIDFunc(filename string) (uint32, error)

DefaultIDFunc is the default IDFunc used by the migrator. It expects the filename to be in the YYYYMMDDHHMMSS_<description>.sql format and defines the ID as the number of seconds since 2023-01-01 00:00:00 UTC.

Types

type IDFunc

type IDFunc func(filename string) (uint32, error)

IDFunc defines a function that validates the migration filename and extracts its numeric ID. The ID must be unique and increasing with each new migration.

type LogFunc

type LogFunc func(msg string, attrs ...any)

LogFunc defines a function used to log the migration process. attrs is a list of key-value pairs, where the key is a string.

type Migrator

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

func New

func New(db *sql.DB, fs fs.ReadDirFS) *Migrator

func (*Migrator) Migrate

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

func (*Migrator) WithIDFunc

func (m *Migrator) WithIDFunc(idFunc IDFunc) *Migrator

func (*Migrator) WithLogFunc

func (m *Migrator) WithLogFunc(logFunc LogFunc) *Migrator

Directories

Path Synopsis
tests module

Jump to

Keyboard shortcuts

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