element

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	Node
	Typ     *types.FieldType
	PgTyp   *ptypes.T
	Options []*ast.ColumnOption
	Comment string
}

Column ...

func (Column) GetType

func (c Column) GetType() byte

GetType ...

func (Column) HasDefaultValue

func (c Column) HasDefaultValue() bool

HasDefaultValue ...

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
	// MigrateRenameAction ...
	MigrateRenameAction
)

type Migration

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

Migration ...

func NewMigration

func NewMigration(isPostgres, isLower bool) Migration

NewMigration ...

func (*Migration) AddColumn

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

AddColumn ...

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) RemoveIndex

func (m *Migration) RemoveIndex(tbName string, 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 Table

type Table struct {
	Node

	Columns []Column

	Indexes []Index
	// 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) 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) 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) 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