schemalex

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: MIT Imports: 8 Imported by: 0

README

schemalex-deploy

Generate the difference of two mysql schema, and deploy it.

Test Go Reference Coverage Status

SYNOPSIS

TODO: fill me

SEE ALSO

LICENSE

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option interface {
	Name() string
	Value() interface{}
}

Option is a generic interface for objects that passes optional parameters to the various format functions in this package

type ParseError

type ParseError interface {
	error
	File() string
	Line() int
	Col() int
	Message() string
	EOF() bool
}

ParseError is returned from the various `Parse` methods when an invalid or unsupported SQL is found. When stringified, the result will look something like this:

parse error: expected RPAREN at line 3 column 14
    "CREATE TABLE foo " <---- AROUND HERE

type Parser

type Parser struct{}

Parser is responsible to parse a set of SQL statements

func New

func New() *Parser

New creates a new Parser

func (*Parser) Parse

func (p *Parser) Parse(src []byte) (model.Stmts, error)

Parse parses the given set of SQL statements and creates a model.Stmts structure. If it encounters errors while parsing, the returned error will be a ParseError type.

func (*Parser) ParseString

func (p *Parser) ParseString(src string) (model.Stmts, error)

ParseString parses a string containing SQL statements and creates a mode.Stmts structure. See Parse for details.

type Token

type Token struct {
	Type  TokenType
	Value string
	Pos   int
	Line  int
	Col   int
	EOF   bool
}

Token represents a token

func NewToken

func NewToken(t TokenType, v string) *Token

NewToken creates a new token of type `t`, with value `v`

func (Token) Ident added in v0.0.5

func (t Token) Ident() model.Ident

Ident returns an identifier. It is only meaningful if the Type is IDENT or BACKTICK_IDENT. The caller must check it.

type TokenType

type TokenType int

TokenType describes the possible types of tokens that schemalex understands

const (
	ILLEGAL TokenType = iota
	EOF
	SPACE
	IDENT
	BACKTICK_IDENT
	DOUBLE_QUOTE_IDENT
	SINGLE_QUOTE_IDENT
	NUMBER
	LPAREN        // (
	RPAREN        // )
	COMMA         // ,
	SEMICOLON     // ;
	DOT           // .
	SLASH         // /
	ASTERISK      // *
	DASH          // -
	PLUS          // +
	SINGLE_QUOTE  // '
	DOUBLE_QUOTE  // "
	EQUAL         // =
	COMMENT_IDENT // // /*   */, --, #
	ACTION
	ASC
	AUTO_INCREMENT
	AVG_ROW_LENGTH
	BIGINT
	BINARY
	BIT
	BLOB
	BOOL
	BOOLEAN
	BTREE
	CASCADE
	CHAR
	CHARACTER
	CHARSET
	CHECK
	CHECKSUM
	COLLATE
	COMMENT
	COMPACT
	COMPRESSED
	CONNECTION
	CONSTRAINT
	CREATE
	CURRENT_TIMESTAMP
	DATA
	DATABASE
	DATE
	DATETIME
	DECIMAL
	DEFAULT
	DELAY_KEY_WRITE
	DELETE
	DESC
	DIRECTORY
	DISK
	DOUBLE
	DROP
	DYNAMIC
	ENGINE
	ENUM
	EXISTS
	FALSE
	FIRST
	FIXED
	FLOAT
	FOREIGN
	FULL
	FULLTEXT
	GEOMETRY
	GEOMETRYCOLLECTION
	HASH
	IF
	INDEX
	INSERT_METHOD
	INT
	INTEGER
	JSON
	KEY_BLOCK_SIZE
	KEY
	LAST
	LIKE
	LINESTRING
	LONGBLOB
	LONGTEXT
	MATCH
	MAX_ROWS
	MEDIUMBLOB
	MEDIUMINT
	MEDIUMTEXT
	MEMORY
	MIN_ROWS
	MULTILINESTRING
	MULTIPOINT
	MULTIPOLYGON
	NO
	NOT
	NOW
	NULL
	NUMERIC
	ON
	PACK_KEYS
	PARSER
	PARTIAL
	PASSWORD
	POINT
	POLYGON
	PRIMARY
	REAL
	REDUNDANT
	REFERENCES
	RESTRICT
	ROW_FORMAT
	SET
	SIMPLE
	SMALLINT
	SPATIAL
	SRID
	STATS_AUTO_RECALC
	STATS_PERSISTENT
	STATS_SAMPLE_PAGES
	STORAGE
	TABLE
	TABLESPACE
	TEMPORARY
	TEXT
	TIME
	TIMESTAMP
	TINYBLOB
	TINYINT
	TINYTEXT
	TRUE
	UNION
	UNIQUE
	UNSIGNED
	UPDATE
	USE
	USING
	VARBINARY
	VARCHAR
	WITH
	YEAR
	ZEROFILL
)

List of possible tokens

func (TokenType) String

func (t TokenType) String() string

Directories

Path Synopsis
cmd
Package diff contains functions to generate SQL statements to migrate an old schema to the new schema
Package diff contains functions to generate SQL statements to migrate an old schema to the new schema
internal

Jump to

Keyboard shortcuts

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