msc

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Snash

func Snash(p Config) error

Snash make DB model snapshot and saves to file

func Struct2json

func Struct2json(s interface{}) map[string]interface{}

Types

type Config

type Config struct {
	User        string
	Pass        string
	Host        string
	Port        string
	DB          string
	FilesPath   string
	File        string
	Prefix      string
	DTable      bool
	DColumn     bool
	DIndex      bool
	DConstraint bool
	Optimize    bool
}

Config Main configuration object

type Constrain

type Constrain struct {
	UPDATE_RULE            string `json:"UPDATE_RULE"`
	DELETE_RULE            string `json:"DELETE_RULE"`
	CONSTRAINT_NAME        string `json:"CONSTRAINT_NAME"`
	COLUMN_NAME            string `json:"COLUMN_NAME"`
	REFERENCED_TABLE_NAME  string `json:"REFERENCED_TABLE_NAME"`
	REFERENCED_COLUMN_NAME string `json:"REFERENCED_COLUMN_NAME"`
}

Constrain Constrain structure

type DBConn

type DBConn struct {
	Conn   *sql.DB
	Prefix string
	Scheme string
}

DBConn DBConnecition

func (*DBConn) GetConstraines

func (d *DBConn) GetConstraines(table string) ([]Constrain, error)

GetConstraines get list of tables in a DB

func (*DBConn) GetFields

func (d *DBConn) GetFields(table string) ([]Field, error)

GetFields get list of tables in a DB

func (*DBConn) GetIndexes

func (d *DBConn) GetIndexes(table string) ([]Index, error)

GetIndexes get list of tables in a DB

func (*DBConn) GetTables

func (d *DBConn) GetTables() ([]Table, error)

GetTables get list of tables in a DB

func (*DBConn) SQLConnect

func (d *DBConn) SQLConnect(dsn string) error

SQLConnect connect to DB

type Field

type Field struct {
	ORDINAL_POSITION string  `json:"ORDINAL_POSITION"`
	COLUMN_COMMENT   string  `json:"COLUMN_COMMENT"`
	COLUMN_NAME      string  `json:"COLUMN_NAME"`
	COLUMN_DEFAULT   *string `json:"COLUMN_DEFAULT"`
	IS_NULLABLE      string  `json:"IS_NULLABLE"`
	DATA_TYPE        string  `json:"DATA_TYPE"`
	COLUMN_TYPE      string  `json:"COLUMN_TYPE"`
	EXTRA            string  `json:"EXTRA"`
	COLUMN_KEY       string  `json:"COLUMN_KEY"`
}

Field Field structure

type Index

type Index struct {
	Table         string  `json:"Table"`
	Non_unique    string  `json:"Non_unique"`
	Key_name      string  `json:"Key_name"`
	Seq_in_index  string  `json:"Seq_in_index"`
	Column_name   string  `json:"Column_name"`
	Collation     *string `json:"Collation"`
	Cardinality   *string `json:"Cardinality"`
	Sub_part      *string `json:"Sub_part"`
	Packed        *string `json:"Packed"`
	Null          string  `json:"Null"`
	Index_type    string  `json:"Index_type"`
	Comment       string  `json:"Comment"`
	Index_comment string  `json:"Index_comment"`
}

Index Index structure

type Restore

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

Restore DB model from file

func (*Restore) Run

func (r *Restore) Run(p Config) error

Run DB model from file

type Table

type Table struct {
	Name          string  `json:"Name"`
	Engine        string  `json:"Engine"`
	Version       int     `json:"Version"`
	RowFormat     string  `json:"Row_format"`
	Rows          int     `json:"Rows"`
	AvgRowLength  int     `json:"Avg_row_length"`
	DataLength    int     `json:"Data_length"`
	MaxDataLength int     `json:"Max_data_length"`
	IndexLength   int     `json:"Index_length"`
	DataFree      int     `json:"Data_free"`
	AutoIncrement *string `json:"Auto_increment"`
	CreateTime    *string `json:"Create_time"`
	UpdateTime    *string `json:"Update_time"`
	CheckTime     *string `json:"Check_time"`
	Collation     string  `json:"Collation"`
	Checksum      *string `json:"Checksum"`
	CreateOptions string  `json:"Create_options"`
	Comment       string  `json:"Comment"`
}

Table table structure

Jump to

Keyboard shortcuts

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