core

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INITMigrations = ""
	MIGRATIONSplit = "_"
	MIGRATIONPath  = "/migrations/"
	INITContent    = "package migrations\n\ntype Migrations struct{}\n"
)
View Source
const (
	TIMEFormat       = "20060102150405"
	NORMALTimeFormat = "2006-01-02 15:04:05"
)
View Source
const (
	ADDIndexStr          = "core.ADDIndex"
	DELETEIndexStr       = "core.DELETEIndex"
	ADDUniqueIndexStr    = "core.ADDUniqueIndex"
	DELETEUniqueIndexStr = "core.DELETEUniqueIndex"
)
View Source
const (
	APPLIED = 1
)
View Source
const PACKAGEPATH = "github.com/lhypj/gorm-migrate/core"

Variables

This section is empty.

Functions

func PrintTree

func PrintTree(root *OperationsNode, blank string)

func ShowTree

func ShowTree(root *OperationsNode)

Types

type ActionType

type ActionType uint8
const (
	ADDField ActionType = iota
	DELETEField
	ALTERField
	ADDTable
	DELETETable
	ADDIndex
	DELETEIndex
	ADDUniqueIndex
	DELETEUniqueIndex
)

type Args

type Args struct {
	Command   string `required:"true"`
	Reversion string
}

type Field

type Field struct {
	Name      string
	Type      string
	IsPrimary bool
}

type Index

type Index struct {
	Name      string
	FieldName []string
}

type Migrate

type Migrate struct {
	DB                 *gorm.DB
	PackagePath        string
	ModelsRelativePath string
	Migrations         interface{}
	Models             []interface{}
}

func (*Migrate) Applied

func (m *Migrate) Applied() map[string]int

func (*Migrate) AppliedOrdered

func (m *Migrate) AppliedOrdered() []string

func (*Migrate) DownGrade

func (m *Migrate) DownGrade(version string)

func (*Migrate) Fake

func (m *Migrate) Fake(version string)

func (*Migrate) GetOperations

func (m *Migrate) GetOperations() []*Operations

func (*Migrate) GetOperationsTree

func (m *Migrate) GetOperationsTree(withValid bool) *OperationsNode

func (*Migrate) HeadToString

func (m *Migrate) HeadToString(root *OperationsNode) []string

func (*Migrate) Heads

func (m *Migrate) Heads(root *OperationsNode, ret map[string]int)

func (*Migrate) List

func (m *Migrate) List()

func (*Migrate) MakeMigrations

func (m *Migrate) MakeMigrations()

func (*Migrate) Merge

func (m *Migrate) Merge()

func (*Migrate) Migrate

func (m *Migrate) Migrate()

func (*Migrate) MigrationsEnd

func (m *Migrate) MigrationsEnd(fn string, latest []string) string

func (*Migrate) MigrationsInit

func (m *Migrate) MigrationsInit()

func (*Migrate) MigrationsMergeContent

func (m *Migrate) MigrationsMergeContent(fn string, heads []string) string

func (*Migrate) MigrationsPath

func (m *Migrate) MigrationsPath() string

func (*Migrate) MigrationsPre

func (m *Migrate) MigrationsPre(fn string) string

func (*Migrate) ModelsPath

func (m *Migrate) ModelsPath() string

func (*Migrate) RootPath

func (*Migrate) RootPath() (string, error)

func (*Migrate) Run

func (m *Migrate) Run()

func (*Migrate) UnApplied

func (m *Migrate) UnApplied() []*Operations

func (*Migrate) Valid

func (m *Migrate) Valid(root *OperationsNode)

type Operation

type Operation struct {
	Action          ActionType
	TableName       string
	ColumnName      string
	Type            string
	TypeNew         string
	IsPrimary       bool
	IndexName       string
	IndexFieldNames []string
}

type OperationSlice

type OperationSlice []*Operations

func (OperationSlice) Len

func (ops OperationSlice) Len() int

func (OperationSlice) Less

func (ops OperationSlice) Less(i, j int) bool

func (OperationSlice) Swap

func (ops OperationSlice) Swap(i, j int)

type Operations

type Operations struct {
	Revision     string
	DownRevision []string
	Operations   []*Operation
}

type OperationsNode

type OperationsNode struct {
	Ops      *Operations
	Children []*OperationsNode
}

func GenerateOperationsTree

func GenerateOperationsTree(operations *[]*Operations) *OperationsNode

func GenerateTree

func GenerateTree(m map[string]*Operations, children map[string][]*Operations, revision string) *OperationsNode

func (*OperationsNode) GetTable

func (root *OperationsNode) GetTable() map[string]*Table

func (*OperationsNode) IsRoot

func (n *OperationsNode) IsRoot() bool

type OrmMigrations

type OrmMigrations struct {
	gorm.Model
	Name string `gorm:"unique;not null;size:30"`
}

type Table

type Table struct {
	Name          string
	Fields        []*Field
	Indexes       []*Index
	UniqueIndexes []*Index
}

Jump to

Keyboard shortcuts

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