migrate

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const TABLE_MIGRATIONS = "CREATE TABLE IF NOT EXISTS sqle_migrations(" +
	"checksum varchar(32) NOT NULL," +
	"module varchar(45) NOT NULL," +
	"version varchar(45) NOT NULL," +
	"name varchar(45) NOT NULL," +
	"rank int NOT NULL DEFAULT '0'," +
	"migrated_on datetime NOT NULL," +
	"execution_time varchar(25) NOT NULL," +
	"scripts text NOT NULL," +
	"PRIMARY KEY (checksum));"
View Source
const TABLE_ROTATIONS = "CREATE TABLE IF NOT EXISTS sqle_rotations(" +
	"checksum varchar(32) NOT NULL," +
	"rotated_name varchar(8) NOT NULL," +
	"name varchar(45) NOT NULL," +
	"rotated_on datetime NOT NULL," +
	"execution_time varchar(25) NOT NULL," +
	"PRIMARY KEY (checksum, rotated_name));"

Variables

View Source
var (
	ErrInvalidScriptName  = errors.New("migrate: invalid script name")
	ErrInvalidRotateRange = errors.New("migrate: invalid rotate range")
)

Functions

This section is empty.

Types

type Migration

type Migration struct {
	Name     string
	Rank     int
	Checksum string
	Scripts  string

	Rotate      shardid.TableRotate
	RotateBegin time.Time
	RotateEnd   time.Time

	MigratedOn    *time.Time
	ExecutionTime time.Duration
}

type MigrationStatus added in v1.5.4

type MigrationStatus int
const (
	MigrationStatusNew      MigrationStatus = iota // new migration, needs to be executed
	MigrationStatusExecuted                        // already executed, checksum matches
	MigrationStatusModified                        // already executed but checksum changed
)

type Migrator

type Migrator struct {
	Versions         []Semver
	MonthlyRotations []Rotation
	WeeklyRotations  []Rotation
	DailyRotations   []Rotation
	// contains filtered or unexported fields
}

func New

func New(dbs ...*sqle.DB) *Migrator

func (*Migrator) Discover

func (m *Migrator) Discover(fsys fs.FS, options ...Option) error

func (*Migrator) Init

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

func (*Migrator) Len

func (s *Migrator) Len() int

func (*Migrator) Less

func (s *Migrator) Less(i, j int) bool

func (*Migrator) Migrate

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

func (*Migrator) Rotate added in v1.2.2

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

func (*Migrator) Swap

func (s *Migrator) Swap(i, j int)

type Option

type Option func(m *Migrator)

func WithModule added in v1.3.2

func WithModule(name string) Option

func WithSuffix

func WithSuffix(suffix string) Option

type Rotation added in v1.2.2

type Rotation struct {
	Name     string
	Checksum string
	Script   string
}

type Semver

type Semver struct {
	Name       string
	Major      int
	Minor      int
	Patch      int
	Prerelease string
	Build      string
	Migrations []Migration
}

func (*Semver) Len

func (s *Semver) Len() int

func (*Semver) Less

func (s *Semver) Less(i, j int) bool

func (*Semver) Swap

func (s *Semver) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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