migrator

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTableName = "schema_migrations"

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger interface {
	Printf(string, ...interface{})
}

Logger interface

type LoggerFunc

type LoggerFunc func(string, ...interface{})

LoggerFunc adapts Logger and any third party logger

func (LoggerFunc) Printf

func (f LoggerFunc) Printf(msg string, args ...interface{})

Printf implements Logger interface

type Migration

type Migration struct {
	Name  string
	File  string
	Run   func(db *sql.DB) error
	RunTx func(db *sql.Tx) error
	// contains filtered or unexported fields
}

func (*Migration) Id

func (m *Migration) Id() int

func (*Migration) String

func (m *Migration) String() string

type Migrator

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

func NewMigrate

func NewMigrate(db *sql.DB, opts ...Option) *Migrator

func (*Migrator) Add

func (m *Migrator) Add(mi ...*Migration)

func (*Migrator) BeginTx

func (m *Migrator) BeginTx() (*sql.Tx, error)

func (*Migrator) CountApplied

func (m *Migrator) CountApplied() (int, error)

func (*Migrator) Exec

func (m *Migrator) Exec(query string, args ...string) error

func (*Migrator) Migrate

func (m *Migrator) Migrate() error

func (*Migrator) Pending

func (m *Migrator) Pending() ([]*Migration, error)

func (*Migrator) TableDrop

func (m *Migrator) TableDrop(table string) error

type Option

type Option func(migrate *Migrator)

func WithEmbedFS

func WithEmbedFS(embedFS embed.FS) Option

func WithLogger

func WithLogger(logger Logger) Option

func WithSchemaFile

func WithSchemaFile(file string) Option

func WithSchemaString

func WithSchemaString(schema string) Option

func WithTableName

func WithTableName(table string) Option

Jump to

Keyboard shortcuts

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