Documentation ¶
Index ¶
- Constants
- type Action
- type AddColumn
- type AddConstraint
- type AlterColumnDropDefault
- type AlterConstraint
- type AlterTableAction
- type AlterTableOption
- type AlterTableStmt
- type CheckConstraint
- type Column
- type ColumnIdent
- type Constraint
- type Constraints
- type CreateIndexStmt
- type CreateTableStmt
- type DDL
- type DataType
- type Default
- type DiffCreateTableConfig
- type DiffCreateTableOption
- type DropColumn
- type DropConstraint
- type DropIndexStmt
- type DropTableStmt
- type Expr
- type ForeignKeyConstraint
- type Ident
- type IndexConstraint
- type Lexer
- type Literal
- type ModifyColumn
- type Object
- type ObjectName
- type Option
- type Options
- type Order
- type Parser
- type PrimaryKeyConstraint
- type RenameColumn
- type RenameConstraint
- type RenameTable
- type Stmt
- type Token
- type TokenType
- type Verb
Constants ¶
const ( Dialect = "mysql" DriverName = "mysql" Indent = " " CommentPrefix = "-- " )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddColumn ¶
type AddColumn struct {
Column *Column
}
AddColumn represents ALTER TABLE table_name ADD COLUMN.
type AddConstraint ¶
type AddConstraint struct { Name *Ident Constraint Constraint NotValid bool }
AddConstraint represents ALTER TABLE table_name ADD CONSTRAINT.
func (*AddConstraint) GoString ¶
func (s *AddConstraint) GoString() string
type AlterColumnDropDefault ¶
type AlterColumnDropDefault struct {
Name *Ident
}
AlterColumnDropDefault represents ALTER TABLE table_name ALTER COLUMN column_name DROP DEFAULT.
func (*AlterColumnDropDefault) GoString ¶
func (s *AlterColumnDropDefault) GoString() string
type AlterConstraint ¶
AlterConstraint represents ALTER TABLE table_name ALTER CONSTRAINT.
func (*AlterConstraint) GoString ¶
func (s *AlterConstraint) GoString() string
type AlterTableAction ¶
type AlterTableAction interface { GoString() string // contains filtered or unexported methods }
type AlterTableOption ¶ added in v0.0.11
AlterTableOption represents ALTER TABLE table_name TABLE_OPTION=option_value.
func (*AlterTableOption) GoString ¶ added in v0.0.11
func (s *AlterTableOption) GoString() string
func (*AlterTableOption) String ¶ added in v0.0.11
func (s *AlterTableOption) String() string
type AlterTableStmt ¶
type AlterTableStmt struct { Comment string Indent string Name *ObjectName Action AlterTableAction }
func (*AlterTableStmt) GetNameForDiff ¶
func (s *AlterTableStmt) GetNameForDiff() string
func (*AlterTableStmt) GoString ¶
func (s *AlterTableStmt) GoString() string
func (*AlterTableStmt) String ¶
func (s *AlterTableStmt) String() string
type CheckConstraint ¶
CheckConstraint represents a CHECK constraint.
func (*CheckConstraint) GetName ¶
func (c *CheckConstraint) GetName() *Ident
func (*CheckConstraint) GoString ¶
func (c *CheckConstraint) GoString() string
func (*CheckConstraint) String ¶
func (c *CheckConstraint) String() string
func (*CheckConstraint) StringForDiff ¶
func (c *CheckConstraint) StringForDiff() string
type Column ¶
type ColumnIdent ¶
func (*ColumnIdent) GoString ¶
func (i *ColumnIdent) GoString() string
func (*ColumnIdent) String ¶
func (i *ColumnIdent) String() string
func (*ColumnIdent) StringForDiff ¶
func (i *ColumnIdent) StringForDiff() string
type Constraint ¶
type Constraints ¶
type Constraints []Constraint
func (Constraints) Append ¶
func (constraints Constraints) Append(constraint Constraint) Constraints
type CreateIndexStmt ¶
type CreateIndexStmt struct { Comment string Unique bool IfNotExists bool Name *ObjectName TableName *ObjectName Using []*Ident Columns []*ColumnIdent }
func (*CreateIndexStmt) GetNameForDiff ¶
func (s *CreateIndexStmt) GetNameForDiff() string
func (*CreateIndexStmt) GoString ¶
func (s *CreateIndexStmt) GoString() string
func (*CreateIndexStmt) String ¶
func (s *CreateIndexStmt) String() string
func (*CreateIndexStmt) StringForDiff ¶
func (s *CreateIndexStmt) StringForDiff() string
type CreateTableStmt ¶
type CreateTableStmt struct { Comment string Indent string IfNotExists bool Name *ObjectName Columns []*Column Constraints Constraints Options Options }
func (*CreateTableStmt) GetNameForDiff ¶
func (s *CreateTableStmt) GetNameForDiff() string
func (*CreateTableStmt) GoString ¶
func (s *CreateTableStmt) GoString() string
func (*CreateTableStmt) String ¶
func (s *CreateTableStmt) String() string
type DDL ¶
type DDL struct {
Stmts []Stmt
}
func DiffCreateTable ¶
func DiffCreateTable(before, after *CreateTableStmt, opts ...DiffCreateTableOption) (*DDL, error)
type DataType ¶
func (*DataType) StringForDiff ¶
type DiffCreateTableConfig ¶
type DiffCreateTableConfig struct {
UseAlterTableAddConstraintNotValid bool
}
type DiffCreateTableOption ¶
type DiffCreateTableOption interface {
// contains filtered or unexported methods
}
func DiffCreateTableUseAlterTableAddConstraintNotValid ¶
func DiffCreateTableUseAlterTableAddConstraintNotValid(notValid bool) DiffCreateTableOption
type DropColumn ¶
type DropColumn struct {
Name *Ident
}
DropColumn represents ALTER TABLE table_name DROP COLUMN.
func (*DropColumn) GoString ¶
func (s *DropColumn) GoString() string
type DropConstraint ¶
type DropConstraint struct {
Name *Ident
}
DropConstraint represents ALTER TABLE table_name DROP CONSTRAINT.
func (*DropConstraint) GoString ¶
func (s *DropConstraint) GoString() string
type DropIndexStmt ¶
type DropIndexStmt struct { Comment string IfExists bool Name *ObjectName }
func (*DropIndexStmt) GetNameForDiff ¶
func (s *DropIndexStmt) GetNameForDiff() string
func (*DropIndexStmt) GoString ¶
func (s *DropIndexStmt) GoString() string
func (*DropIndexStmt) String ¶
func (s *DropIndexStmt) String() string
type DropTableStmt ¶
type DropTableStmt struct { Comment string IfExists bool Name *ObjectName }
func (*DropTableStmt) GetNameForDiff ¶
func (s *DropTableStmt) GetNameForDiff() string
func (*DropTableStmt) GoString ¶
func (s *DropTableStmt) GoString() string
func (*DropTableStmt) String ¶
func (s *DropTableStmt) String() string
type ForeignKeyConstraint ¶
type ForeignKeyConstraint struct { Name *Ident Columns []*ColumnIdent Ref *Ident RefColumns []*ColumnIdent OnAction string }
ForeignKeyConstraint represents a FOREIGN KEY constraint.
func (*ForeignKeyConstraint) GetName ¶
func (c *ForeignKeyConstraint) GetName() *Ident
func (*ForeignKeyConstraint) GoString ¶
func (c *ForeignKeyConstraint) GoString() string
func (*ForeignKeyConstraint) String ¶
func (c *ForeignKeyConstraint) String() string
func (*ForeignKeyConstraint) StringForDiff ¶
func (c *ForeignKeyConstraint) StringForDiff() string
type IndexConstraint ¶
type IndexConstraint struct { Name *Ident Unique bool Columns []*ColumnIdent }
IndexConstraint represents a UNIQUE constraint..
func (*IndexConstraint) GetName ¶
func (c *IndexConstraint) GetName() *Ident
func (*IndexConstraint) GoString ¶
func (c *IndexConstraint) GoString() string
func (*IndexConstraint) String ¶
func (c *IndexConstraint) String() string
func (*IndexConstraint) StringForDiff ¶
func (c *IndexConstraint) StringForDiff() string
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
Lexer はSQL文をトークンに分割するレキサーです。
type ModifyColumn ¶ added in v0.0.12
type ModifyColumn struct { Name *Ident DataType *DataType CharacterSet *Ident Collate *Ident NotNull bool AutoIncrement bool Default *Default OnAction string Comment string }
ModifyColumn represents ALTER TABLE table_name MODIFY column_name data_type NOT NULL. NOTE: https://dev.mysql.com/doc/refman/8.0/ja/alter-table-examples.html
func (*ModifyColumn) GoString ¶ added in v0.0.12
func (s *ModifyColumn) GoString() string
type ObjectName ¶
func NewObjectName ¶
func NewObjectName(name string) *ObjectName
func (*ObjectName) String ¶
func (t *ObjectName) String() string
func (*ObjectName) StringForDiff ¶
func (t *ObjectName) StringForDiff() string
type Option ¶
func (*Option) StringForDiff ¶ added in v0.0.11
type Options ¶ added in v0.0.11
type Options []*Option
func (Options) StringForDiff ¶ added in v0.0.11
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser はSQL文を解析するパーサーです。
type PrimaryKeyConstraint ¶
type PrimaryKeyConstraint struct { Name *Ident Columns []*ColumnIdent }
PrimaryKeyConstraint represents a PRIMARY KEY constraint.
func (*PrimaryKeyConstraint) GetName ¶
func (c *PrimaryKeyConstraint) GetName() *Ident
func (*PrimaryKeyConstraint) GoString ¶
func (c *PrimaryKeyConstraint) GoString() string
func (*PrimaryKeyConstraint) String ¶
func (c *PrimaryKeyConstraint) String() string
func (*PrimaryKeyConstraint) StringForDiff ¶
func (c *PrimaryKeyConstraint) StringForDiff() string
type RenameColumn ¶
RenameColumn represents ALTER TABLE table_name RENAME COLUMN.
func (*RenameColumn) GoString ¶
func (s *RenameColumn) GoString() string
type RenameConstraint ¶
RenameConstraint represents ALTER TABLE table_name RENAME COLUMN.
func (*RenameConstraint) GoString ¶
func (s *RenameConstraint) GoString() string
type RenameTable ¶
type RenameTable struct {
NewName *ObjectName
}
RenameTable represents ALTER TABLE table_name RENAME TO new_table_name.
func (*RenameTable) GoString ¶
func (s *RenameTable) GoString() string
type TokenType ¶
type TokenType string
const ( // SPECIAL TOKENS. TOKEN_ILLEGAL TokenType = "ILLEGAL" TOKEN_EOF TokenType = "EOF" // SPECIAL CHARACTERS. TOKEN_OPEN_PAREN TokenType = "OPEN_PAREN" // ( TOKEN_CLOSE_PAREN TokenType = "CLOSE_PAREN" // ) TOKEN_COMMA TokenType = "COMMA" // , TOKEN_SEMICOLON TokenType = "SEMICOLON" // ; TOKEN_EQUAL TokenType = "EQUAL" // = TOKEN_GREATER TokenType = "GREATER" // > TOKEN_LESS TokenType = "LESS" // < TOKEN_PLUS TokenType = "PLUS" // + TOKEN_MINUS TokenType = "MINUS" // - TOKEN_ASTERISK TokenType = "ASTERISK" // * TOKEN_SLASH TokenType = "SLASH" // / TOKEN_STRING_CONCAT TokenType = "STRING_CONCAT" //nolint:gosec // || TOKEN_TYPECAST TokenType = "TYPECAST" // :: TOKEN_TYPE_ANNOTATION TokenType = "TYPE_ANNOTATION" // ::: // VERB. TOKEN_CREATE TokenType = "CREATE" TOKEN_ALTER TokenType = "ALTER" TOKEN_DROP TokenType = "DROP" TOKEN_RENAME TokenType = "RENAME" TOKEN_TRUNCATE TokenType = "TRUNCATE" // OBJECT. TOKEN_TABLE TokenType = "TABLE" TOKEN_INDEX TokenType = "INDEX" TOKEN_VIEW TokenType = "VIEW" // OTHER. TOKEN_IF TokenType = "IF" TOKEN_EXISTS TokenType = "EXISTS" TOKEN_USING TokenType = "USING" TOKEN_ON TokenType = "ON" TOKEN_UPDATE TokenType = "UPDATE" TOKEN_DELETE TokenType = "DELETE" TOKEN_CASCADE TokenType = "CASCADE" TOKEN_RESTRICT TokenType = "RESTRICT" TOKEN_NO TokenType = "NO" TOKEN_ACTION TokenType = "ACTION" TOKEN_TO TokenType = "TO" TOKEN_SET TokenType = "SET" // DATA TYPE. TOKEN_BOOLEAN TokenType = "BOOLEAN" TOKEN_BIT TokenType = "BIT" TOKEN_TINYINT TokenType = "TINYINT" TOKEN_SMALLINT TokenType = "SMALLINT" TOKEN_MEDIUMINT TokenType = "MEDIUMINT" TOKEN_INTEGER TokenType = "INTEGER" TOKEN_BIGINT TokenType = "BIGINT" TOKEN_DECIMAL TokenType = "DECIMAL" TOKEN_NUMERIC TokenType = "NUMERIC" TOKEN_REAL TokenType = "REAL" TOKEN_DOUBLE TokenType = "DOUBLE" TOKEN_PRECISION TokenType = "PRECISION" TOKEN_DOUBLE_PRECISION TokenType = "DOUBLE PRECISION" TOKEN_SMALLSERIAL TokenType = "SMALLSERIAL" TOKEN_SERIAL TokenType = "SERIAL" TOKEN_BIGSERIAL TokenType = "BIGSERIAL" TOKEN_JSON TokenType = "JSON" TOKEN_CHAR TokenType = "CHAR" TOKEN_CHARACTER_VARYING TokenType = "CHARACTER VARYING" TOKEN_CHARACTER TokenType = "CHARACTER" TOKEN_VARYING TokenType = "VARYING" TOKEN_VARCHAR TokenType = "VARCHAR" TOKEN_TEXT TokenType = "TEXT" TOKEN_MEDIUMTEXT TokenType = "MEDIUMTEXT" TOKEN_LONGTEXT TokenType = "LONGTEXT" TOKEN_DATETIME TokenType = "DATETIME" TOKEN_TIMESTAMP TokenType = "TIMESTAMP" TOKEN_DATE TokenType = "DATE" TOKEN_TIME TokenType = "TIME" TOKEN_ENUM TokenType = "ENUM" // COLUMN. TOKEN_DEFAULT TokenType = "DEFAULT" TOKEN_NOT TokenType = "NOT" TOKEN_ASC TokenType = "ASC" TOKEN_DESC TokenType = "DESC" TOKEN_COMMENT TokenType = "COMMENT" // CONSTRAINT. TOKEN_CONSTRAINT TokenType = "CONSTRAINT" TOKEN_PRIMARY TokenType = "PRIMARY" TOKEN_KEY TokenType = "KEY" TOKEN_FOREIGN TokenType = "FOREIGN" TOKEN_REFERENCES TokenType = "REFERENCES" TOKEN_UNIQUE TokenType = "UNIQUE" TOKEN_CHECK TokenType = "CHECK" // OPTIONS. TOKEN_ENGINE TokenType = "ENGINE" TOKEN_CHARSET TokenType = "CHARSET" TOKEN_COLLATE TokenType = "COLLATE" // FUNCTION. TOKEN_AUTO_INCREMENT TokenType = "AUTO_INCREMENT" //nolint:gosec TOKEN_CURRENT_TIMESTAMP TokenType = "CURRENT_TIMESTAMP" TOKEN_NULLIF TokenType = "NULLIF" // VALUE. TOKEN_NULL TokenType = "NULL" TOKEN_TRUE TokenType = "TRUE" TOKEN_FALSE TokenType = "FALSE" // IDENTIFIER. TOKEN_IDENT TokenType = "IDENT" )