migration

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: May 6, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppliedVersion

type AppliedVersion struct {
	ID          int64
	Version     string
	AppliedAt   string // Store as string for compatibility
	Description string
}

AppliedVersion represents a record in the schema_migrations table

type MigrationFile

type MigrationFile struct {
	Version   int64  // 版本号
	Name      string // 描述性名称
	Direction string // 方向 ("up" or "down")
	FilePath  string // 完整文件路径
}

MigrationFile 代表一个迁移脚本文件

func DiscoverMigrations

func DiscoverMigrations(dir string) ([]MigrationFile, error)

DiscoverMigrations 在指定目录中发现并排序迁移脚本文件

type Migrator

type Migrator struct {
	Db thing.DBAdapter
	// contains filtered or unexported fields
}

Migrator handles database migrations

func NewMigrator

func NewMigrator(db thing.DBAdapter, migrationsDir string) *Migrator

NewMigrator creates a new Migrator instance

func (*Migrator) EnableLog

func (m *Migrator) EnableLog(enable bool)

EnableLog enables/disables logging

func (*Migrator) Migrate

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

Migrate applies pending migrations

Jump to

Keyboard shortcuts

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