migfinalize

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Finalizer

type Finalizer[DB any, TX any] struct {
	Ctx        context.Context
	DB         *DB
	Log        *internal.Log
	BeginTx    func(context.Context, *DB) (*TX, error)
	BodyTx     func(context.Context, *TX) error        // executes inside tx or runs outside work using pooled conn; returns error for body
	SaveStatus func(context.Context, *TX, error) error // persist final outcome (err==nil success)
	CommitTx   func(*TX) error
	RollbackTx func(*TX)
	SetDone    func()
	SetError   func(error)
}

Finalizer orchestrates a migration attempt and status persistence. It exists to allow unit testing of the logic and to make the logic shared between database drivers.

Assumptions / rules:

  • TX must be a pointer type (e.g. *sql.Tx); we rely on direct nil comparisons.
  • No optional callbacks: every function field must be set (supply no-op when unused).
  • Any opened transaction that isn't committed gets rolled back by a dedicated defer.

func (*Finalizer[DB, TX]) Run

func (f *Finalizer[DB, TX]) Run() (finalErr error)

Jump to

Keyboard shortcuts

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