Documentation ¶
Index ¶
- Constants
- type Action
- type AddColumn
- type AddConstraint
- type AlterColumnDropDefault
- type AlterColumnDropNotNull
- type AlterColumnSetDataType
- type AlterColumnSetDefault
- type AlterColumnSetNotNull
- type AlterConstraint
- type AlterTableAction
- 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 Object
- type ObjectName
- type Option
- type Order
- type Parser
- type PrimaryKeyConstraint
- type RenameColumn
- type RenameConstraint
- type RenameTable
- type Stmt
- type Token
- type TokenType
- type Verb
Constants ¶
const ( Dialect = "cockroachdb" //diff:ignore-line-postgres-cockroach DriverName = "postgres" // cockroachdb's driver is postgres //diff:ignore-line-postgres-cockroach 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 { 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 AlterColumnDropNotNull ¶
type AlterColumnDropNotNull struct {
Name *Ident
}
AlterColumnDropNotNull represents ALTER TABLE table_name ALTER COLUMN column_name DROP NOT NULL.
func (*AlterColumnDropNotNull) GoString ¶
func (s *AlterColumnDropNotNull) GoString() string
type AlterColumnSetDataType ¶
AlterColumnSetDataType represents ALTER TABLE table_name ALTER COLUMN column_name SET DATA TYPE.
func (*AlterColumnSetDataType) GoString ¶
func (s *AlterColumnSetDataType) GoString() string
type AlterColumnSetDefault ¶
AlterColumnSetDefault represents ALTER TABLE table_name ALTER COLUMN column_name SET DEFAULT.
func (*AlterColumnSetDefault) GoString ¶
func (s *AlterColumnSetDefault) GoString() string
type AlterColumnSetNotNull ¶
type AlterColumnSetNotNull struct {
Name *Ident
}
AlterColumnSetNotNull represents ALTER TABLE table_name ALTER COLUMN column_name SET NOT NULL.
func (*AlterColumnSetNotNull) GoString ¶
func (s *AlterColumnSetNotNull) 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 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 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 *Ident 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 []*Option }
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 ¶
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 //diff:ignore-line-postgres-cockroach Columns []*ColumnIdent }
IndexConstraint represents a UNIQUE constraint. //diff:ignore-line-postgres-cockroach.
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 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 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" // ::: //diff:ignore-line-postgres-cockroach // VERB. TOKEN_CREATE TokenType = "CREATE" TOKEN_ALTER TokenType = "ALTER" TOKEN_DROP TokenType = "DROP" TOKEN_RENAME TokenType = "RENAME" TOKEN_TRUNCATE TokenType = "TRUNCATE" TOKEN_DELETE TokenType = "DELETE" TOKEN_UPDATE TokenType = "UPDATE" // 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_TO TokenType = "TO" // DATA TYPE. TOKEN_BOOL TokenType = "BOOL" //diff:ignore-line-postgres-cockroach TOKEN_INT2 TokenType = "INT2" //diff:ignore-line-postgres-cockroach TOKEN_INT4 TokenType = "INT4" //diff:ignore-line-postgres-cockroach TOKEN_INT8 TokenType = "INT8" //diff:ignore-line-postgres-cockroach 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_FLOAT4 TokenType = "FLOAT4" TOKEN_FLOAT8 TokenType = "FLOAT8" TOKEN_SMALLSERIAL TokenType = "SMALLSERIAL" TOKEN_SERIAL TokenType = "SERIAL" TOKEN_BIGSERIAL TokenType = "BIGSERIAL" TOKEN_UUID TokenType = "UUID" TOKEN_JSONB TokenType = "JSONB" TOKEN_CHARACTER_VARYING TokenType = "CHARACTER VARYING" TOKEN_CHARACTER TokenType = "CHARACTER" TOKEN_VARYING TokenType = "VARYING" TOKEN_VARCHAR TokenType = "VARCHAR" //diff:ignore-line-postgres-cockroach TOKEN_STRING TokenType = "STRING" //diff:ignore-line-postgres-cockroach TOKEN_TIMESTAMPTZ TokenType = "TIMESTAMPTZ" TOKEN_TIMESTAMP TokenType = "TIMESTAMP" TOKEN_WITH TokenType = "WITH" TOKEN_TIME TokenType = "TIME" TOKEN_ZONE TokenType = "ZONE" // COLUMN. TOKEN_DEFAULT TokenType = "DEFAULT" TOKEN_NOT TokenType = "NOT" TOKEN_ASC TokenType = "ASC" TOKEN_DESC TokenType = "DESC" TOKEN_CASCADE TokenType = "CASCADE" TOKEN_NO TokenType = "NO" TOKEN_ACTION TokenType = "ACTION" // 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" // FUNCTION. TOKEN_NULLIF TokenType = "NULLIF" // VALUE. TOKEN_NULL TokenType = "NULL" TOKEN_TRUE TokenType = "TRUE" TOKEN_FALSE TokenType = "FALSE" // IDENTIFIER. TOKEN_IDENT TokenType = "IDENT" )