Documentation
¶
Index ¶
- Constants
- Variables
- func AddPlan(dir string, plan *Plan, project, engine string) error
- func ConvertUri2Dsn(uri string) (string, error)
- func DbUri2Dsn(params *Params) string
- func InitProject(project *ProjectInfo) error
- func RegisterEngine(name string, eng Engine)
- type ConfParser
- type Config
- type Database
- type Engine
- type Field
- type Log
- type Manager
- type Params
- type Plan
- type PlanParser
- type ProjectInfo
- type Rule
Constants ¶
View Source
const ( LogsTable = `dbvm_logs` // 日志表名称 ConfFile = `dbvm.yaml` PlanFile = `dbvm.plan` DeployDir = `deploy` RevertDir = `revert` )
默认配置
Variables ¶
View Source
var ( MagicIgnore = []byte(`IGNORE`) // 忽略指定的错误 MagicNoTrans = []byte(`NO-TRANS`) // 不需要启动事务 )
魔法注释
Functions ¶
func ConvertUri2Dsn ¶ added in v0.2.5
ConvertUri2Dsn 直接将DB-URI转换为DSN
Types ¶
type Config ¶
type Config struct {
Engine string `yaml:"engine"` // 优先使用dburi中的engine
FromTable string `yaml:"fromTable"` // 重命名日志表
LogsTable string `yaml:"logsTable"` // [default= dbvm_logs]
Rule *Rule `yaml:"rule"`
}
Config 数据库配置
type Engine ¶
type Engine interface {
// Connect 连接到数据库
Connect(*Params) error
// Close 关闭数据库连接
Close()
// Initiate 初始化日志表
Initiate(string) error
// ListLogs 获取版本更新历史
ListLogs() ([]*Log, error)
// Deploy 部署指定版本
Deploy(*Plan) error
// Revert 回退指定版本
Revert(*Plan) error
}
Engine 数据库驱动引擎
type Log ¶
type Log struct {
ID uint32 // 日志ID, 可选
Name string // 版本名称,必须
Time uint64 // 部署时间,可选
Status uint8 // 完成状态,必须(0未完成,1已完成)
}
Log 数据库操作日志
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager 管理器,非线程安全
func NewWithParser ¶
func NewWithParser(dir, dburi string, confParser ConfParser, planParser PlanParser) (mgr *Manager, err error)
NewWithParser 自定义配置解析
type Params ¶
type Params struct {
Engine string
Username string
Password string
Host string
Port string
Database string
Query string
Fragment string
}
Params 数据库参数 Engine & Database can't be empty
func ParseDbUri ¶
ParseDbUri 从URI字符串中解析数据库参数
type Plan ¶
type Plan struct {
Name string
Requires []string
Time time.Time
User string
Hostname string
Note string
Deploy string
Revert string
// contains filtered or unexported fields
}
Plan 执行计划
type PlanParser ¶
PlanParser 部署计划解析函数
Click to show internal directories.
Click to hide internal directories.