Documentation ¶
Index ¶
- Constants
- Variables
- func CheckFileExist(filename string) (exists bool)
- func Output(slice interface{}, grid Grid)
- func StringLength(r []rune) int
- func WriteFile(filename, content string) (n int, err error)
- type Config
- type Grid
- type Migrate
- func (m Migrate) Create(filename string) (err error)
- func (m Migrate) ExecDown(filename string) (err error)
- func (m Migrate) ExecUp() (err error)
- func (m Migrate) FindMigrations() ([]*Migration, error)
- func (m Migrate) GetExecutedMigrations() (migrations []MigrationModel, err error)
- func (m Migrate) InitMigrationTable() (err error)
- func (m Migrate) Status() (err error)
- type Migration
- type MigrationModel
- type MigrationOutput
- type ParsedMigration
Constants ¶
View Source
const ( MigrationUp uint8 = 1 MigrationDown uint8 = 2 )
迁移操作
Variables ¶
View Source
var ( // LineSeparator can be used to split migrations by an exact line match. This line // will be removed from the output. If left blank, it is not considered. It is defaulted // to blank so you will have to set it manually. // Use case: in MSSQL, it is convenient to separate commands by GO statements like in // SQL Query Analyzer. LineSeparator = "" )
Functions ¶
Types ¶
type Grid ¶
type Grid string
Grid Grid
const GridASCII Grid = "ascii"
GridASCII ascii格式表格
const GridBoxDrawing Grid = "box-drawing"
GridBoxDrawing box-drawing格式表格
type Migrate ¶
type Migrate struct {
// contains filtered or unexported fields
}
Migrate Migrate对象
func (Migrate) FindMigrations ¶
FindMigrations 读取全部迁移文件
func (Migrate) GetExecutedMigrations ¶
func (m Migrate) GetExecutedMigrations() (migrations []MigrationModel, err error)
GetExecutedMigrations 获取已执行的迁移记录
func (Migrate) InitMigrationTable ¶
InitMigrationTable 初始化数据迁移表
type Migration ¶
type Migration struct { Id string Up []string Down []string DisableTransactionUp bool DisableTransactionDown bool }
Migration 解析后的迁移文件数据结构
func (Migration) NumberPrefixMatches ¶
NumberPrefixMatches NumberPrefixMatches
type MigrationModel ¶
type MigrationModel struct { ID uint64 `json:"id"` Migration string `json:"migration"` CreatedAt time.Time `json:"created_at"` }
MigrationModel MigrationModel
type MigrationOutput ¶
MigrationOutput 列表输出
type ParsedMigration ¶
type ParsedMigration struct { UpStatements []string DownStatements []string DisableTransactionUp bool DisableTransactionDown bool }
func ParseMigration ¶
func ParseMigration(r io.ReadSeeker) (*ParsedMigration, error)
Split the given sql script into individual statements.
The base case is to simply split on semicolons, as these naturally terminate a statement.
However, more complex cases like pl/pgsql can have semicolons within a statement. For these cases, we provide the explicit annotations 'StatementBegin' and 'StatementEnd' to allow the script to tell us to ignore semicolons.
Click to show internal directories.
Click to hide internal directories.