element

package
v0.0.0-...-347ad93 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	Node

	CurrentAttr  SqlAttr
	PreviousAttr SqlAttr
}

Column ...

func (Column) Constraint

func (c Column) Constraint() string

Constraint ...

func (Column) DataType

func (c Column) DataType() string

DataType ...

func (Column) GetType

func (c Column) GetType() byte

GetType ...

func (Column) HasDefaultValue

func (c Column) HasDefaultValue() bool

HasDefaultValue ...

type ForeignKey

type ForeignKey struct {
	Node
	Table      string
	Column     string
	RefTable   string
	RefColumn  string
	Constraint string
}

ForeignKey ...

type Index

type Index struct {
	Node
	Typ       ast.IndexKeyType
	IndexType model.IndexType
	CnsTyp    ast.ConstraintType
	Columns   []string
}

Index ...

type MigrateAction

type MigrateAction int8

MigrateAction ...

const (
	// MigrateNoAction ...
	MigrateNoAction MigrateAction = iota
	// MigrateAddAction ...
	MigrateAddAction
	// MigrateRemoveAction ...
	MigrateRemoveAction
	// MigrateModifyAction ...
	MigrateModifyAction
	// MigrateRevertAction ...
	MigrateRevertAction
	// MigrateRenameAction ...
	MigrateRenameAction
)

type Migration

type Migration struct {
	Tables []Table
	// contains filtered or unexported fields
}

Migration ...

func NewMigration

func NewMigration(dialect sql_templates.SqlDialect, lowercase, ignoreOrder bool) Migration

NewMigration ...

func (*Migration) AddColumn

func (m *Migration) AddColumn(tbName string, col Column)

AddColumn ...

func (*Migration) AddComment

func (m *Migration) AddComment(tbName, colName, comment string)

AddIndex ...

func (*Migration) AddForeignKey

func (m *Migration) AddForeignKey(tbName string, fk ForeignKey)

AddForeignKey ...

func (*Migration) AddIndex

func (m *Migration) AddIndex(tbName string, idx Index)

AddIndex ...

func (*Migration) AddTable

func (m *Migration) AddTable(tb Table)

AddTable ...

func (*Migration) Diff

func (m *Migration) Diff(old Migration)

Diff differ between 2 migrations

func (Migration) HashValue

func (m Migration) HashValue() int64

HashValue ...

func (Migration) MigrationDown

func (m Migration) MigrationDown() string

MigrationDown ...

func (Migration) MigrationUp

func (m Migration) MigrationUp() string

MigrationUp ...

func (*Migration) RemoveColumn

func (m *Migration) RemoveColumn(tbName, colName string)

RemoveColumn ...

func (*Migration) RemoveForeignKey

func (m *Migration) RemoveForeignKey(tbName, fkName string)

RemoveForeignKey ...

func (*Migration) RemoveIndex

func (m *Migration) RemoveIndex(tbName, idxName string)

RemoveIndex ...

func (*Migration) RemoveTable

func (m *Migration) RemoveTable(tbName string)

RemoveTable ...

func (*Migration) RenameColumn

func (m *Migration) RenameColumn(tbName, oldName, newName string)

RenameColumn ...

func (*Migration) RenameIndex

func (m *Migration) RenameIndex(tbName, oldName, newName string)

RenameIndex ...

func (*Migration) RenameTable

func (m *Migration) RenameTable(oldName, newName string)

RenameTable ...

func (*Migration) SetColumnPosition

func (m *Migration) SetColumnPosition(tbName string, pos *ast.ColumnPosition)

SetColumnPosition ...

func (*Migration) Using

func (m *Migration) Using(tbName string)

Using set current table

type Node

type Node struct {
	Name    string
	OldName string
	Action  MigrateAction
}

Node primitive element

type SqlAttr

type SqlAttr struct {
	MysqlType *types.FieldType
	PgType    *ptypes.T
	LiteType  *sqlite.Type
	Options   []*ast.ColumnOption
	Comment   string
}

type Table

type Table struct {
	Node

	Columns []Column

	Indexes []Index

	ForeignKeys []ForeignKey
	// contains filtered or unexported fields
}

Table ...

func NewTable

func NewTable(name string) *Table

NewTable ...

func NewTableWithAction

func NewTableWithAction(name string, action MigrateAction) *Table

NewTableWithAction ...

func (*Table) AddColumn

func (t *Table) AddColumn(col Column)

AddColumn ...

func (*Table) AddForeignKey

func (t *Table) AddForeignKey(fk ForeignKey)

AddForeignKey ...

func (*Table) AddIndex

func (t *Table) AddIndex(idx Index)

AddIndex ...

func (*Table) Arrange

func (t *Table) Arrange()

Arrange correct column order

func (*Table) Diff

func (t *Table) Diff(old Table)

Diff differ between 2 migrations

func (Table) MigrationColumnDown

func (t Table) MigrationColumnDown() ([]string, map[string]struct{})

MigrationColumnDown ...

func (Table) MigrationColumnUp

func (t Table) MigrationColumnUp() ([]string, map[string]struct{})

MigrationColumnUp ...

func (Table) MigrationForeignKeyDown

func (t Table) MigrationForeignKeyDown(dropCols map[string]struct{}) []string

MigrationForeignKeyDown ...

func (Table) MigrationForeignKeyUp

func (t Table) MigrationForeignKeyUp(dropCols map[string]struct{}) []string

MigrationForeignKeyUp ...

func (Table) MigrationIndexDown

func (t Table) MigrationIndexDown(dropCols map[string]struct{}) []string

MigrationIndexDown ...

func (Table) MigrationIndexUp

func (t Table) MigrationIndexUp(dropCols map[string]struct{}) []string

MigrationIndexUp ...

func (*Table) RemoveForeignKey

func (t *Table) RemoveForeignKey(fkName string)

RemoveForeignKey ...

func (*Table) RemoveIndex

func (t *Table) RemoveIndex(idxName string)

RemoveIndex ...

func (*Table) RenameColumn

func (t *Table) RenameColumn(oldName, newName string)

RenameColumn ...

func (*Table) RenameIndex

func (t *Table) RenameIndex(oldName, newName string)

RenameIndex ...

Jump to

Keyboard shortcuts

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