metas

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MapRouterKeyDelimiter = ":"

Functions

func GenerateMapRouterKey

func GenerateMapRouterKey(schema string, table string) string

func GenerateMapRouterVersionKey added in v0.0.2

func GenerateMapRouterVersionKey(schema string, table string, version uint) string

func SplitMapRouterKey

func SplitMapRouterKey(key string) (schema string, table string)

func SplitMapRouterVersionKey added in v0.0.2

func SplitMapRouterVersionKey(key string) (schema string, table string, version uint)

func TableDdlHandle added in v0.1.0

func TableDdlHandle(tab *Table, sql string) error

func TableRestore added in v0.1.0

func TableRestore(astNode interface{}) (rawSql string, err error)

Types

type Column

type Column struct {
	Name         string
	Type         ColumnType
	RawType      string
	Comment      string
	IsPrimaryKey bool
}

type ColumnType

type ColumnType = int
const (
	TypeNumber    ColumnType = iota + 1 // tinyint, smallint, mediumint, int, bigint, year
	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 ColumnsMapper

type ColumnsMapper struct {
	PrimaryKeys    []string // source
	SourceColumns  []string
	TargetColumns  []string
	MapMapper      map[string]string
	MapMapperOrder []string
}

type DdlStatement

type DdlStatement struct {
	Schema        string
	Name          string
	RawSql        string
	IsAlterTable  bool
	IsCreateTable bool
	CreateTable   struct {
		IsLikeCreateTable bool
		ReferTable        struct {
			Schema string
			Name   string
		}
		IsSelectCreateTable bool
		SelectRawSql        string
	}
	IsDropTable     bool
	IsRenameTable   bool
	IsTruncateTable bool
}

func TableDdlParser added in v0.1.0

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

type Router

type Router struct {
	SourceSchema  string `mapstructure:"source-schema"`
	SourceTable   string `mapstructure:"source-table"`
	TargetSchema  string `mapstructure:"target-schema"`
	TargetTable   string `mapstructure:"target-table"`
	DmlTopic      string `mapstructure:"dml-topic"`
	ColumnsMapper ColumnsMapper
}

type Routers

type Routers struct {
	Raws []*Router
	Maps map[string]*Router
}

func (*Routers) InitRouters

func (r *Routers) InitRouters(config map[string]interface{}) error

type Table

type Table struct {
	Schema            string
	Name              string
	Comment           string
	Columns           []Column
	PrimaryKeyColumns []Column
	Version           uint
}

func NewTable added in v0.1.0

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

func (*Table) DeepCopy added in v0.0.2

func (t *Table) DeepCopy() (*Table, error)

Jump to

Keyboard shortcuts

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