schema

package
v0.0.0-...-c39d001 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TYPE_NUMBER    = iota + 1 // tinyint, smallint, mediumint, int, bigint, year
	TYPE_FLOAT                // float, double
	TYPE_ENUM                 // enum
	TYPE_SET                  // set
	TYPE_STRING               // other
	TYPE_DATETIME             // datetime
	TYPE_TIMESTAMP            // timestamp
	TYPE_DATE                 // date
	TYPE_TIME                 // time
	TYPE_BIT                  // bit
	TYPE_JSON                 // json
)

Variables

View Source
var ErrMissingTableMeta = errors.New("missing table meta")
View Source
var ErrTableNotExist = errors.New("table is not exist")
View Source
var HAHealthCheckSchema = "mysql.ha_health_check"

Functions

func IsTableExist

func IsTableExist(conn mysql.Executer, schema string, name string) (bool, error)

Types

type Index

type Index struct {
	Name        string
	Columns     []string
	Cardinality []uint64
}

func NewIndex

func NewIndex(name string) *Index

func (*Index) AddColumn

func (idx *Index) AddColumn(name string, cardinality uint64)

func (*Index) FindColumn

func (idx *Index) FindColumn(name string) int

type Table

type Table struct {
	Schema string
	Name   string

	Columns   []TableColumn
	Indexes   []*Index
	PKColumns []int
}

func NewTable

func NewTable(conn mysql.Executer, schema string, name string) (*Table, error)

func NewTableFromSqlDB

func NewTableFromSqlDB(conn *sql.DB, schema string, name string) (*Table, error)

func (*Table) AddColumn

func (ta *Table) AddColumn(name string, columnType string, collation string, extra string)

func (*Table) AddIndex

func (ta *Table) AddIndex(name string) (index *Index)

func (*Table) FindColumn

func (ta *Table) FindColumn(name string) int

func (*Table) GetPKColumn

func (ta *Table) GetPKColumn(index int) *TableColumn

func (*Table) String

func (ta *Table) String() string

type TableColumn

type TableColumn struct {
	Name       string
	Type       int
	Collation  string
	RawType    string
	IsAuto     bool
	IsUnsigned bool
	EnumValues []string
	SetValues  []string
}

Jump to

Keyboard shortcuts

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