golumn

package module
v0.0.0-...-81bd2b1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2025 License: BSD-3-Clause Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

golumn

Script Go database migrations with embedded Lua.

Documentation

Index

Constants

View Source
const (
	UpTargetLatest    = -1
	DownTargetInitial = -1
)

Variables

View Source
var (
	ErrLocked         = errors.New("version store is locked for writing")
	ErrInitialVersion = errors.New("initial version is current")
)

Functions

func GenScript

func GenScript(v int64, name string) (string, error)

func GenScriptTimestamp

func GenScriptTimestamp(name string) (version int64, filename string, script string, err error)

func WriteScript

func WriteScript(v int64, name string, p string) error

func WriteScriptTimestamp

func WriteScriptTimestamp(name string, dir string) (version int64, outpath string, err error)

Types

type GlobLoader

type GlobLoader struct {
	Pattern string
}

func (GlobLoader) Load

func (l GlobLoader) Load(ctx context.Context) ([]*Migration, error)

type Loader

type Loader interface {
	Load(context.Context) ([]*Migration, error)
}

type Migration

type Migration struct {
	Version  int64
	Name     string
	UpFunc   func(context.Context, *sql.DB) error
	DownFunc func(context.Context, *sql.DB) error
}

func Parse

func Parse(ctx context.Context, r io.Reader, name string) (*Migration, error)

func (*Migration) Down

func (m *Migration) Down(ctx context.Context, db *sql.DB) error

func (*Migration) Up

func (m *Migration) Up(ctx context.Context, db *sql.DB) error

type Migrator

type Migrator struct {
	Store   Store
	Sources []*Migration
	LogW    io.Writer
	DebugW  io.Writer

	HoldLockOnFailure bool
}

func (*Migrator) Down

func (m *Migrator) Down(ctx context.Context, to int64) (err error)

func (*Migrator) Up

func (m *Migrator) Up(ctx context.Context, to int64) (err error)

type Store

type Store interface {
	DB() *sql.DB
	Init(context.Context) error
	Lock(context.Context) error
	Release(context.Context) error
	Version(context.Context) (int64, error)
	Insert(context.Context, int64) error
	Remove(context.Context, int64) error
}

Directories

Path Synopsis
stores

Jump to

Keyboard shortcuts

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