schema

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: GPL-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const MongoName = "mongo"
View Source
const MysqlName = "mysql"

Variables

This section is empty.

Functions

func TableDdlHandle added in v0.6.0

func TableDdlHandle(tab *Table, sql string) error

Types

type ColumnType

type ColumnType = int
const (
	TypeNumber    ColumnType = iota + 1 // tinyint, smallint, int, bigint, year
	TypeMediumInt                       // medium int
	TypeFloat                           // float, double
	TypeEnum                            // enum
	TypeSet                             // set
	TypeString                          // other
	TypeDatetime                        // datetime
	TypeTimestamp                       // timestamp
	TypeDate                            // date
	TypeTime                            // time
	TypeBit                             // bit
	TypeJson                            // json
	TypeDecimal                         // decimal
	TypeBinary                          // binary
)

type DdlStatement added in v0.6.0

type DdlStatement struct {
	Schema            string `toml:"schema" json:"schema"`
	Name              string `toml:"name" json:"name"`
	RawSql            string `toml:"raw_sql" json:"raw_sql"`
	IsCreateTable     bool   `toml:"is_create_table" json:"is_create_table"`
	IsLikeCreateTable bool   `toml:"is_like_create_table" json:"is_like_create_table"`
	ReferTable        struct {
		Schema string `toml:"schema" json:"schema"`
		Name   string `toml:"name" json:"name"`
	} `toml:"refer_table" json:"refer_table"`
	IsSelectCreateTable bool   `toml:"is_select_create_table" json:"is_select_create_table"`
	SelectRawSql        string `toml:"select_raw_sql" json:"select_raw_sql"`
	IsDropTable         bool   `toml:"is_drop_table" json:"is_drop_table"`
	IsRenameTable       bool   `toml:"is_rename_table" json:"is_rename_table"`
}

func DdlToDdlStatements added in v0.6.0

func DdlToDdlStatements(sql string, schema string) ([]*DdlStatement, error)

type MongoTables

type MongoTables struct {
	*config.MongoConfig
	// contains filtered or unexported fields
}

func (*MongoTables) AddTable

func (mts *MongoTables) AddTable(db string, table string) (*Table, error)

func (*MongoTables) AddTableForMsg

func (mts *MongoTables) AddTableForMsg(msg *msg.Msg) error

func (*MongoTables) Close

func (mts *MongoTables) Close()

func (*MongoTables) Configure added in v0.5.0

func (mts *MongoTables) Configure(pipelineName string, configInput map[string]interface{}) error

func (*MongoTables) DelTable added in v0.4.1

func (mts *MongoTables) DelTable(db string, table string) error

func (*MongoTables) GetTable

func (mts *MongoTables) GetTable(db string, table string) (*Table, error)

func (*MongoTables) NewSchemaTables

func (mts *MongoTables) NewSchemaTables(conf *config.BaseConfig, pluginConfig map[string]interface{}, startPos string, rulesMap map[string]interface{})

func (*MongoTables) RefreshTable

func (mts *MongoTables) RefreshTable(db string, table string)

func (*MongoTables) SaveMeta added in v0.3.3

func (mts *MongoTables) SaveMeta(data string) error

func (*MongoTables) UpdateTable

func (mts *MongoTables) UpdateTable(db string, table string, args interface{}, pos string, index int) (err error)

type MysqlTables

type MysqlTables struct {
	sync.RWMutex
	*config.MysqlConfig

	*MysqlTablesMeta

	FilePath string
	// contains filtered or unexported fields
}

func (*MysqlTables) AddTable

func (mts *MysqlTables) AddTable(db string, table string) (*Table, error)

func (*MysqlTables) AddTableForMsg

func (mts *MysqlTables) AddTableForMsg(msg *msg.Msg) error

func (*MysqlTables) Close

func (mts *MysqlTables) Close()

func (*MysqlTables) Configure added in v0.5.0

func (mts *MysqlTables) Configure(pipelineName string, configInput map[string]interface{}) error

func (*MysqlTables) DelTable added in v0.4.1

func (mts *MysqlTables) DelTable(db string, table string) (err error)

func (*MysqlTables) ExecuteSQL

func (mts *MysqlTables) ExecuteSQL(cmd string, args ...interface{}) (rr *mysql.Result, err error)

func (*MysqlTables) ExecuteSQLForMetaDB added in v0.5.0

func (mts *MysqlTables) ExecuteSQLForMetaDB(cmd string, args ...interface{}) (rr *mysql.Result, err error)

func (*MysqlTables) GetTable

func (mts *MysqlTables) GetTable(db string, table string) (*Table, error)

func (*MysqlTables) GetTableCreateDDL added in v0.5.0

func (mts *MysqlTables) GetTableCreateDDL(db string, table string) (string, error)

func (*MysqlTables) LoadMetaFromDB

func (mts *MysqlTables) LoadMetaFromDB(rulesMap map[string]interface{}) map[string]interface{}

func (*MysqlTables) LoadSyncTableMetaFromDB added in v0.5.0

func (mts *MysqlTables) LoadSyncTableMetaFromDB() map[string]interface{}

func (*MysqlTables) NewSchemaTables

func (mts *MysqlTables) NewSchemaTables(conf *config.BaseConfig, pluginConfig map[string]interface{}, startPos string, rulesMap map[string]interface{})

func (*MysqlTables) RefreshTable

func (mts *MysqlTables) RefreshTable(db string, table string)

func (*MysqlTables) SaveMeta

func (mts *MysqlTables) SaveMeta(tablesMeta string) error

func (*MysqlTables) StartTimerSaveMeta added in v0.5.0

func (mts *MysqlTables) StartTimerSaveMeta()

func (*MysqlTables) UpdateTable

func (mts *MysqlTables) UpdateTable(db string, table string, ddl interface{}, pos string, index int) (err error)

type MysqlTablesMeta

type MysqlTablesMeta struct {
	// contains filtered or unexported fields
}

type Table

type Table struct {
	Schema            string        `toml:"schema" json:"schema"`
	Name              string        `toml:"name" json:"name"`
	Comment           string        `toml:"comment" json:"comment"`
	Columns           []TableColumn `toml:"columns" json:"columns"`
	PrimaryKeyColumns []TableColumn `toml:"primary_key_columns" json:"primary_key_columns"`
}

func NewTable added in v0.6.0

func NewTable(createDdlSql string) (*Table, error)

func (*Table) DelColumn added in v0.3.3

func (t *Table) DelColumn(name string) error

func (*Table) FindColumn

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

func (*Table) GetTableColumnsName

func (t *Table) GetTableColumnsName() []string

func (*Table) ToString added in v0.6.0

func (t *Table) ToString() string

type TableColumn

type TableColumn struct {
	Name         string     `toml:"name" json:"name"`
	Type         ColumnType `toml:"type" json:"type"`
	RawType      string     `toml:"raw_type" json:"raw_type"`
	Comment      string     `toml:"comment" json:"comment"`
	IsPrimaryKey bool       `toml:"is_primary_key" json:"is_primary_key"`
}

Jump to

Keyboard shortcuts

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