Documentation
¶
Index ¶
Constants ¶
View Source
const ( MigrationMarker = "-- [CHECK POINT] --" TimeFormat = "2006-01-02 15:04:05" DefaultProgressSuffix = ".progress" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBProgressStore ¶
type DBProgressStore struct {
// contains filtered or unexported fields
}
DBProgressStore 数据库进度存储
func NewDBProgressStore ¶
func NewDBProgressStore(db *gorm.DB, scriptPath string) *DBProgressStore
NewDBProgressStore 创建数据库进度存储
type FileProgressStore ¶
type FileProgressStore struct {
// contains filtered or unexported fields
}
FileProgressStore 文件进度存储
func NewFileProgressStore ¶
func NewFileProgressStore(path string) *FileProgressStore
NewFileProgressStore 创建文件进度存储
type FileScriptReader ¶
type FileScriptReader struct {
// contains filtered or unexported fields
}
FileScriptReader 文件脚本读取器
func NewFileScriptReader ¶
func NewFileScriptReader(path string) *FileScriptReader
NewFileScriptReader 创建文件脚本读取器
type MigrationError ¶
MigrationError 自定义错误类型
func (*MigrationError) Error ¶
func (e *MigrationError) Error() string
func (*MigrationError) Unwrap ¶
func (e *MigrationError) Unwrap() error
type MigrationProgress ¶
type MigrationProgress struct {
ID uint `gorm:"primaryKey"`
ScriptPath string `gorm:"index;size:255;not null"`
LineNum int `gorm:"not null"`
UpdatedAt time.Time
}
MigrationProgress 迁移进度记录(数据库存储模型)
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
Migrator 数据库迁移器
func NewMigrator ¶
func NewMigrator(db *gorm.DB, scriptPath string, opts ...MigratorOption) *Migrator
NewMigrator 创建一个新的数据库迁移器
type MigratorOption ¶
type MigratorOption func(*Migrator)
MigratorOption 配置选项
func WithProgressStore ¶
func WithProgressStore(s ProgressStore) MigratorOption
WithProgressStore 设置进度存储
func WithScriptReader ¶
func WithScriptReader(r ScriptReader) MigratorOption
WithScriptReader 设置脚本读取器
type ProgressStore ¶
type ProgressStore interface {
// Load 加载上次迁移断点
Load() (int, error)
// Save 保存当前迁移进度
Save(lineNum int) error
}
ProgressStore 进度存储接口
type SQLStatement ¶
SQLStatement 表示一个待执行的 SQL 片段
type ScriptReader ¶
ScriptReader SQL 脚本读取接口
Click to show internal directories.
Click to hide internal directories.