migrator

package
v0.0.0-...-a163782 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvVar          = "ENV"
	CheckOwlStudent = "owl"
)
View Source
const (
	LogLevelDebug = 1
)

Variables

View Source
var (
	Local = "local"
	Pre   = "pre"
	Prod  = "prod"
	Dev   = "dev"
	Test  = "test"
)

Functions

This section is empty.

Types

type CaptureWriter

type CaptureWriter struct {
	// contains filtered or unexported fields
}

func NewCaptureWriter

func NewCaptureWriter(w io.Writer) *CaptureWriter

func (*CaptureWriter) Bytes

func (w *CaptureWriter) Bytes() []byte

func (*CaptureWriter) Write

func (w *CaptureWriter) Write(d []byte) (int, error)

type InputModule

type InputModule struct {
	ModuleName string // 模块名称
	FullName   string // 生成的名称 : 序号_时间戳_模块名(1_1577890090_student)
}

type Migrator

type Migrator struct {
	/*
	 如果强制运行,模块在此RunModules map对应的值为true, 否则为false,
	 如果Module -- all 加 --force, 则全部模块都为true
	*/
	Version string
	// Flags
	AllFlag       bool   // 全部执行标志
	Force         bool   // 强制运行标志
	FakeFlag      bool   // 标记为已运行标志
	Env           string // 工具执行中的环境变量
	OriginEnv     string // 原始运行的环境变量
	ResetEnv      bool   // 是否需要回复运行的环境变量
	AfterHookFlag bool   // 只运行after hook 检查标志

	// Paths
	VersionPath string // 对应的版本路径
	WorkingPath string // 工作路径
	// config
	Infra        *middleware.Infra
	RunRecrod    []db.Schema   // 运行每个脚本后的记录
	InputModules []InputModule // 需要运行的模块
	RunModules   map[string]bool
	RunIndex     indexstruct.IndexConfig // 读取index.json 存放到对象内存中
	LogLevel     int
	Check        string
	// AfterHookPath, 是以migration目录为根目录的相对路径,用于运行监测migration执行完成后时候有同步的工作,暂时写死在init的函数中
	AfterHookPath []string
}

func Init

func Init(all bool, modules []string, version string, force bool, workDir string, fake bool, env, check string) (*Migrator, error)

func (*Migrator) Debug

func (m *Migrator) Debug() bool

func (*Migrator) Fake

func (m *Migrator) Fake()

func (*Migrator) Migrate

func (m *Migrator) Migrate() error

func (*Migrator) Run

func (m *Migrator) Run()

func (*Migrator) Validate

func (m *Migrator) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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