Documentation
¶
Index ¶
- func ColumnType(d Dialect, column Column) (string, error)
- type Column
- type ColumnOption
- func After(after string) ColumnOption
- func AllowNull() ColumnOption
- func AllowedValues(values ...interface{}) ColumnOption
- func AutoIncrement() ColumnOption
- func Charset(charset string) ColumnOption
- func Collation(collation string) ColumnOption
- func Comment(comment string) ColumnOption
- func Default(value interface{}) ColumnOption
- func First(first string) ColumnOption
- func GeneratedAs(expression string, always ...bool) ColumnOption
- func Length(length int) ColumnOption
- func NotAutoIncrement() ColumnOption
- func NotNull() ColumnOption
- func Nullable(nullable bool) ColumnOption
- func Precision(precision int) ColumnOption
- func PrimaryKey() ColumnOption
- func Projection(projection string) ColumnOption
- func Rename(rename string) ColumnOption
- func Scale(scale int) ColumnOption
- func Size(precision int, scale ...int) ColumnOption
- func StoredAs(expression string) ColumnOption
- func Type(dataType DataType) ColumnOption
- func Unsigned() ColumnOption
- func UseCurrent() ColumnOption
- func VirtualAs(expression string) ColumnOption
- type ColumnSchema
- func (c *ColumnSchema) Added() bool
- func (c *ColumnSchema) After() string
- func (c *ColumnSchema) Alawys() bool
- func (c *ColumnSchema) AllowedValues() []interface{}
- func (c *ColumnSchema) Append() string
- func (c *ColumnSchema) AutoIncrement() bool
- func (c *ColumnSchema) Changed() bool
- func (c *ColumnSchema) Charset() string
- func (c *ColumnSchema) Collate() string
- func (c *ColumnSchema) Comment() string
- func (c *ColumnSchema) DataType() DataType
- func (c *ColumnSchema) DefaultValue() interface{}
- func (c *ColumnSchema) First() string
- func (c *ColumnSchema) GeneratedAs() string
- func (c *ColumnSchema) Length() int
- func (c *ColumnSchema) Name() string
- func (c *ColumnSchema) Nullable() bool
- func (c *ColumnSchema) Precision() int
- func (c *ColumnSchema) PrimaryKey() bool
- func (c *ColumnSchema) Projection() string
- func (c *ColumnSchema) Rename() string
- func (c *ColumnSchema) Scale() int
- func (c *ColumnSchema) Srid() int
- func (c *ColumnSchema) StoredAs() string
- func (c *ColumnSchema) Unsigned() bool
- func (c *ColumnSchema) UseCurrent() bool
- func (c *ColumnSchema) VirtualAs() string
- func (c *ColumnSchema) With(options ...ColumnOption) *ColumnSchema
- type ColumnTypeConverter
- type DataType
- type Dialect
- type Index
- type IndexOptions
- type IndexSchema
- type IndexType
- type Query
- type Table
- type TableCommand
- type TableConstraintInfo
- type TableConstraintInfos
- type TableConstraints
- func (t *TableConstraints) AddChecks(checks ...constraint.Check)
- func (t *TableConstraints) AddForeignKeys(keys ...constraint.ForeignKey)
- func (t *TableConstraints) AddUniques(keys ...constraint.Unique)
- func (t *TableConstraints) HasChecks() bool
- func (t *TableConstraints) HasForeignKeys() bool
- func (t *TableConstraints) HasPrimaryKey() bool
- func (t *TableConstraints) HashUniques() bool
- func (t *TableConstraints) SetPrimaryKey(key constraint.PrimaryKey)
- type TableHandler
- type TableOption
- type TableSchema
- func (t *TableSchema) AddCommand(commands ...TableCommand)
- func (t *TableSchema) AddPrimaryKey(columnNames ...string)
- func (t *TableSchema) AddedColumns() []Column
- func (t *TableSchema) BigID(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) BigInt(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) Binary(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) Boolean(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) ChangedColumns() []Column
- func (t *TableSchema) Char(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) Charset() string
- func (t *TableSchema) Collation() string
- func (t *TableSchema) ColumnExists(columnName string) bool
- func (t *TableSchema) Columns() []Column
- func (t *TableSchema) Commands() []TableCommand
- func (t *TableSchema) Comment() string
- func (t *TableSchema) Date(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) DateTime(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) DateTimeTz(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) Decimal(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) Double(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) Drop(name string)
- func (t *TableSchema) DropColumns(columnNames ...string)
- func (t *TableSchema) DropIfExists(name string)
- func (t *TableSchema) DropPrimaryKey()
- func (t *TableSchema) Engine() string
- func (t *TableSchema) Enum(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) Float(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) Geometry(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) GeometryCollection(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) ID(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) IPAddress(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) Index(columnNames []string, options ...IndexOptions)
- func (t *TableSchema) Int(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) IsTemporary() bool
- func (t *TableSchema) Json(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) Jsonb(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) LineString(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) LongText(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) MacAddress(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) MediumInt(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) MediumText(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) Modify(columnName string, options ...ColumnOption)
- func (t *TableSchema) MultiLineString(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) MultiPoint(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) MultiPolygon(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) MultiPolygonZ(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) Name() string
- func (t *TableSchema) Point(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) Polygon(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) Prefix() string
- func (t *TableSchema) PrimaryKey() []string
- func (t *TableSchema) RemoveColumn(name string) *TableSchema
- func (t *TableSchema) Rename(name string)
- func (t *TableSchema) Schema() string
- func (t *TableSchema) Set(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) SetCharset(charset string) *TableSchema
- func (t *TableSchema) SetCollation(collation string) *TableSchema
- func (t *TableSchema) SetComment(comment string) *TableSchema
- func (t *TableSchema) SetEngine(engine string) *TableSchema
- func (t *TableSchema) SetOptions(options string) *TableSchema
- func (t *TableSchema) SetPrefix(prefix string) *TableSchema
- func (t *TableSchema) SetTemporary(temporary bool) *TableSchema
- func (t *TableSchema) SmallInt(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) SpatialIndex(columnNames []string, options ...IndexOptions)
- func (t *TableSchema) String(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) Text(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) Time(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) TimeTz(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) Timestamp(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) TimestampTz(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) TinyInt(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) UUID(name string, options ...ColumnOption) *ColumnSchema
- func (t *TableSchema) Unique(columnNames []string, options ...IndexOptions)
- func (t *TableSchema) Year(name string, options ...ColumnOption) *ColumnSchema
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Column ¶
type Column interface {
Name() string // name of this column (without quotes).
Rename() string // change the name of this column (without quotes).
DataType() DataType // the abstract DB type of this column. Possible DB types vary according to the type of DBMS.
DefaultValue() interface{} // Specify a "default" value for the column, the value type must be a string or fmt.Stringer interface
Nullable() bool // Allow NULL values to be inserted into the column
AllowedValues() []interface{} // set column allowed values when column type is enum or set
Length() int // display size of the column.
Precision() int // precision of the column data, if it is numeric.
Scale() int // scale of the column data, if it is numeric
PrimaryKey() bool // is a primary index
AutoIncrement() bool // Set INTEGER columns as auto-increment (primary key)
Unsigned() bool // whether this column is unsigned. This is only meaningful when [[type]] is `smallint`, `integer` or `bigint`.
GeneratedAs() string // Create a SQL compliant identity column (PostgreSQL)
Alawys() bool // Used as a modifier for generatedAs() (PostgreSQL)
Charset() string // Specify a character set for the column (MySQL)
Collate() string // Specify a collate for the column (MySQL)
After() string // Place the column "after" another column (MySQL)
First() string // Place the column "first" in the table (MySQL)
Append() string // append
Added() bool // Change the columns
Changed() bool // Change the columns
StoredAs() string // the stored generated column (MySQL)
Srid() int // the srid of the column
UseCurrent() bool // the TIMESTAMP column to use CURRENT_TIMESTAMP as default value
VirtualAs() string // the virtual generated column (MySQL)
Projection() string //
Comment() string // the comment of the column
}
Column interface
type ColumnOption ¶
type ColumnOption func(column *ColumnSchema)
func AllowedValues ¶
func AllowedValues(values ...interface{}) ColumnOption
set column allowed values when column type is enum、set
func AutoIncrement ¶
func AutoIncrement() ColumnOption
Set INTEGER columns as auto-increment (primary key)
func Charset ¶
func Charset(charset string) ColumnOption
Specify a character set for the column (MySQL)
func Collation ¶
func Collation(collation string) ColumnOption
Specify a collation for the column (MySQL/PostgreSQL/SQL Server)
func Default ¶
func Default(value interface{}) ColumnOption
Specify a collation for the column (MySQL/PostgreSQL/SQL Server)
func First ¶
func First(first string) ColumnOption
Specify a collation for the column (MySQL/PostgreSQL/SQL Server)
func GeneratedAs ¶
func GeneratedAs(expression string, always ...bool) ColumnOption
Create a SQL compliant identity column (PostgreSQL)
func NotAutoIncrement ¶
func NotAutoIncrement() ColumnOption
Set INTEGER columns as not auto-increment (primary key)
func Precision ¶
func Precision(precision int) ColumnOption
set column precision when column type is decimal
func Size ¶
func Size(precision int, scale ...int) ColumnOption
set column precision and scale when column type is decimal
func StoredAs ¶
func StoredAs(expression string) ColumnOption
Create a stored generated column (MySQL)
func UseCurrent ¶
func UseCurrent() ColumnOption
Set the TIMESTAMP column to use CURRENT_TIMESTAMP as default value
func VirtualAs ¶
func VirtualAs(expression string) ColumnOption
Create a virtual generated column (MySQL)
type ColumnSchema ¶
type ColumnSchema struct {
// contains filtered or unexported fields
}
the column schema
func (*ColumnSchema) Added ¶
func (c *ColumnSchema) Added() bool
func (*ColumnSchema) After ¶
func (c *ColumnSchema) After() string
func (*ColumnSchema) Alawys ¶
func (c *ColumnSchema) Alawys() bool
func (*ColumnSchema) AllowedValues ¶
func (c *ColumnSchema) AllowedValues() []interface{}
func (*ColumnSchema) Append ¶
func (c *ColumnSchema) Append() string
func (*ColumnSchema) AutoIncrement ¶
func (c *ColumnSchema) AutoIncrement() bool
func (*ColumnSchema) Changed ¶
func (c *ColumnSchema) Changed() bool
func (*ColumnSchema) Charset ¶
func (c *ColumnSchema) Charset() string
func (*ColumnSchema) Collate ¶
func (c *ColumnSchema) Collate() string
func (*ColumnSchema) Comment ¶
func (c *ColumnSchema) Comment() string
func (*ColumnSchema) DataType ¶
func (c *ColumnSchema) DataType() DataType
func (*ColumnSchema) DefaultValue ¶
func (c *ColumnSchema) DefaultValue() interface{}
func (*ColumnSchema) First ¶
func (c *ColumnSchema) First() string
func (*ColumnSchema) GeneratedAs ¶
func (c *ColumnSchema) GeneratedAs() string
func (*ColumnSchema) Length ¶
func (c *ColumnSchema) Length() int
func (*ColumnSchema) Name ¶
func (c *ColumnSchema) Name() string
func (*ColumnSchema) Nullable ¶
func (c *ColumnSchema) Nullable() bool
func (*ColumnSchema) Precision ¶
func (c *ColumnSchema) Precision() int
func (*ColumnSchema) PrimaryKey ¶
func (c *ColumnSchema) PrimaryKey() bool
func (*ColumnSchema) Projection ¶
func (c *ColumnSchema) Projection() string
func (*ColumnSchema) Rename ¶
func (c *ColumnSchema) Rename() string
func (*ColumnSchema) Scale ¶
func (c *ColumnSchema) Scale() int
func (*ColumnSchema) Srid ¶
func (c *ColumnSchema) Srid() int
func (*ColumnSchema) StoredAs ¶
func (c *ColumnSchema) StoredAs() string
func (*ColumnSchema) Unsigned ¶
func (c *ColumnSchema) Unsigned() bool
func (*ColumnSchema) UseCurrent ¶
func (c *ColumnSchema) UseCurrent() bool
func (*ColumnSchema) VirtualAs ¶
func (c *ColumnSchema) VirtualAs() string
func (*ColumnSchema) With ¶
func (c *ColumnSchema) With(options ...ColumnOption) *ColumnSchema
set options for column
type ColumnTypeConverter ¶
column type convert func
func ColumnTypeMapper ¶
func ColumnTypeMapper(d Dialect, dataType DataType) (ColumnTypeConverter, error)
get dialect ColumnType func by dialect and column type
type DataType ¶
type DataType string
the abstract DB type of this column
const ( TypeChar DataType = "char" TypeString DataType = "string" TypeText DataType = "text" TypeMediumText DataType = "mediumText" TypeLongText DataType = "longText" TypeTinyInt DataType = "tinyInt" TypeSmallInt DataType = "smallInt" TypeMediumInt DataType = "mediumInt" TypeInt DataType = "int" TypeBigInt DataType = "bigInt" TypeTinyBlob DataType = "tinyBlob" TypeBlob DataType = "blob" TypeMediumBlob DataType = "mediumBlob" TypeLongBlob DataType = "longBlob" TypeFloat DataType = "float" TypeDouble DataType = "double" TypeDecimal DataType = "decimal" TypeDateTime DataType = "datetime" TypeDateTimeTz DataType = "datetimeTz" TypeTimestamp DataType = "timestamp" TypeTimestampTz DataType = "timestampTz" TypeTime DataType = "time" TypeTimeTz DataType = "timeTz" TypeDate DataType = "date" TypeYear DataType = "year" TypeBinary DataType = "binary" TypeBoolean DataType = "boolean" TypeJson DataType = "json" TypeJsonb DataType = "jsonb" TypeEnum DataType = "enum" TypeSet DataType = "set" TypeUUID DataType = "uuid" TypeIpAddress DataType = "ipAddress" TypeMacAddress DataType = "macAddress" TypeGeometry DataType = "geometry" TypePoint DataType = "point" TypeLineString DataType = "lineString" TypePolygon DataType = "polygon" TypeGeometryCollection DataType = "geometryCollection" TypeMultiPoint DataType = "multiPoint" TypeMultiLineString DataType = "multiLineString" TypeMultiPolygon DataType = "multiPolygon" TypeMultiPolygonZ DataType = "MultiPolygonZ" )
func DataTypeMapper ¶
Convert the column type to abstract data type
type Dialect ¶
type Dialect interface {
// Create the column definition for a char type.
TypeChar(column Column) (string, error)
// Create the column definition for a string type.
TypeString(column Column) (string, error)
// Create the column definition for a text type.
TypeText(column Column) (string, error)
// Create the column definition for a medium text type.
TypeMediumText(column Column) (string, error)
// Create the column definition for a long text type.
TypeLongText(column Column) (string, error)
// Create the column definition for a big integer type.
TypeBigInteger(column Column) (string, error)
// Create the column definition for an integer type.
TypeInteger(column Column) (string, error)
// Create the column definition for a medium integer type.
TypeMediumInteger(column Column) (string, error)
// Create the column definition for a tiny integer type.
TypeTinyInteger(column Column) (string, error)
// Create the column definition for a tiny blob type.
TypeTinyBlob(column Column) (string, error)
// Create the column definition for an blob type.
TypeBlob(column Column) (string, error)
// Create the column definition for a medium blob type.
TypeMediumBlob(column Column) (string, error)
// Create the column definition for a long blob type.
TypeLongBlob(column Column) (string, error)
// Create the column definition for a small integer type.
TypeSmallInteger(column Column) (string, error)
// Create the column definition for a float type.
TypeFloat(column Column) (string, error)
// Create the column definition for a double type.
TypeDouble(column Column) (string, error)
// Create the column definition for a decimal type.
TypeDecimal(column Column) (string, error)
// Create the column definition for a boolean type.
TypeBoolean(column Column) (string, error)
// Create the column definition for an enumeration type.
TypeEnum(column Column) (string, error)
// Create the column definition for a set enumeration type.
TypeSet(column Column) (string, error)
// Create the column definition for a json type.
TypeJson(column Column) (string, error)
// Create the column definition for a jsonb type.
TypeJsonb(column Column) (string, error)
// Create the column definition for a date type.
TypeDate(column Column) (string, error)
// Create the column definition for a date-time type.
TypeDateTime(column Column) (string, error)
// Create the column definition for a date-time (with time zone) type.
TypeDateTimeTz(column Column) (string, error)
// Create the column definition for a time type.
TypeTime(column Column) (string, error)
// Create the column definition for a time (with time zone) type.
TypeTimeTz(column Column) (string, error)
// Create the column definition for a timestamp type.
TypeTimestamp(column Column) (string, error)
// Create the column definition for a timestamp (with time zone) type.
TypeTimestampTz(column Column) (string, error)
// Create the column definition for a year type.
TypeYear(column Column) (string, error)
// Create the column definition for a binary type.
TypeBinary(column Column) (string, error)
// Create the column definition for a uuid type.
TypeUuid(column Column) (string, error)
// Create the column definition for an IP address type.
TypeIpAddress(column Column) (string, error)
// Create the column definition for a MAC address type.
TypeMacAddress(column Column) (string, error)
// Create the column definition for a spatial Geometry type.
TypeGeometry(column Column) (string, error)
// Create the column definition for a spatial Point type.
TypePoint(column Column) (string, error)
// Create the column definition for a spatial LineString type.
TypeLineString(column Column) (string, error)
// Create the column definition for a spatial Polygon type.
TypePolygon(column Column) (string, error)
// Create the column definition for a spatial GeometryCollection type.
TypeGeometryCollection(column Column) (string, error)
// Create the column definition for a spatial MultiPoint type.
TypeMultiPoint(column Column) (string, error)
// Create the column definition for a spatial MultiLineString type.
TypeMultiLineString(column Column) (string, error)
// Create the column definition for a spatial MultiPolygon type.
TypeMultiPolygon(column Column) (string, error)
// Modify the column
ModifyColumn(column Column) string
// Compile the query exists of the table
CompileTableExists(tableName string, tableSchema ...string) (string, error)
// Compile the query to determine the list of columns.
CompileColumnListing(tableName string, tableSchema ...string) (string, error)
// Compile a create table command.
CompileCreate(table Table) (string, error)
// Compile a modify columns command.
CompileModifyColumns(table Table) (string, error)
// Compile a modify column command.
CompileModifyColumn(table Table, columnName string) (string, error)
// Compile add columns.
CompileAddColumns(table Table) (string, error)
// Compile add columns.
CompileAddColumn(table Table, columnName string) (string, error)
// Compile a primary key command.
CompilePrimaryKey(table Table, columnNames ...string) (string, error)
// Compile a drop primary key command.
CompileDropPrimaryKey(table Table) (string, error)
// Compile an index creation command.
CompileIndex(table Table, index Index) (string, error)
// Compile a drop index command.
CompileDropIndex(table Table, indexName string) (string, error)
// Compile a drop unique index command.
CompileDropUnique(table Table, indexName string) (string, error)
// Compile a drop spatial index command.
CompileDropSpatialIndex(table Table, indexName string) (string, error)
// Compile a drop foreign index command.
CompileDropForeign(table Table, indexName string) (string, error)
// Compile a drop table command.
CompileDrop(tableName string) (string, error)
// Compile a drop table (if exists) command.
CompileDropIfExists(tableName string) (string, error)
// Compile a drop column command.
CompileDropColumn(table Table, columnNames []string) (string, error)
// Compile a rename table command.
CompileRenameTable(table Table, toName string) (string, error)
// Compile a rename index command.
CompileRenameIndex(table Table, from string, to string) (string, error)
// Compile the SQL needed to drop all tables. [PostgreSQL]
CompileDropAllTables(tableNames ...string) (string, error)
// Compile the SQL needed to drop all views.
CompileDropAllViews(viewNames ...string) (string, error)
// Compile the SQL needed to drop all types.
CompileDropAllTypes(schemaNames ...string) (string, error)
// Compile the SQL needed to retrieve all table names.
CompileGetAllTables(schemaNames ...string) (string, error)
// Compile the SQL needed to retrieve all view names.
CompileGetAllViews(schemaNames ...string) (string, error)
// Compile the SQL needed to retrieve all type names. [PostgreSQL]
CompileGetAllTypes() (string, error)
// Compile the SQL needed to rebuild the database. [SQLite]
CompileRebuild() (string, error)
// Compile the command to enable foreign key constraints.
CompileEnableForeignKeyConstraints() (string, error)
// Compile the command to disable foreign key constraints.
CompileDisableForeignKeyConstraints() (string, error)
// Load table columns from the database
LoadColumns(tableName string, tableSchema ...string) ([]Column, error)
// Load table from the database
LoadTable(tableName string, tableSchema ...string) (Table, error)
// Load table constraints from the database
LoadTableConstraints(tableName string, tableSchema ...string) (TableConstraints, error)
}
schema dialect
type IndexOptions ¶
type IndexOptions func(index *IndexSchema)
func IndexAlgorithm ¶
func IndexAlgorithm(algorithm string) IndexOptions
func IndexComment ¶
func IndexComment(comment string) IndexOptions
func IndexName ¶
func IndexName(name string) IndexOptions
type IndexSchema ¶
type IndexSchema struct {
// contains filtered or unexported fields
}
func (IndexSchema) Algorithm ¶
func (i IndexSchema) Algorithm() string
func (IndexSchema) ColumnNames ¶
func (i IndexSchema) ColumnNames() []string
func (IndexSchema) Comment ¶
func (i IndexSchema) Comment() string
func (IndexSchema) Name ¶
func (i IndexSchema) Name() string
func (IndexSchema) Type ¶
func (i IndexSchema) Type() IndexType
type IndexType ¶
type IndexType string
const ( PrimaryIndex IndexType = "PRIMARY KEY" // UniqueIndex IndexType = "UNIQUE" // NormalIndex IndexType = "INDEX" // SpatialIndex IndexType = "SPATIAL" // [MySQL:SPATIAL] [PostgreSQL:GIST] FullTextIndex IndexType = "FULLTEXT" // [MySQL:FULLTEXT] GistIndex IndexType = "GIST" // [MySQL:SPATIAL] [PostgreSQL:GIST] GinIndex IndexType = "GIN" // [PostgreSQL:GIN] )
type Table ¶
type Table interface {
Name() string // The name of the table
Schema() string // The schema of the table
Prefix() string // The prefix of the table.
Engine() string // The storage engine that should be used for the table.
Charset() string // The default character set that should be used for the table.
Collation() string // The collation that should be used for the table.
IsTemporary() bool // Whether to make the table temporary.
Comment() string // the comment of the table
Columns() []Column // The columns that should be added to the table.
PrimaryKey() []string // The primary keys of the table
AddedColumns() []Column // the added columns
ChangedColumns() []Column // the changed columns
Commands() []TableCommand // the table commands
}
The table interface
type TableCommand ¶
type TableConstraintInfo ¶
type TableConstraintInfo struct {
Name string `db:"name"`
ColumnName string `db:"column_name"`
Type string `db:"type"`
ForeignTableSchema sql.NullString `db:"foreign_table_schema"`
ForeignTableName sql.NullString `db:"foreign_table_name"`
ForeignColumnName sql.NullString `db:"foreign_column_name"`
OnUpdate sql.NullString `db:"on_update"`
OnDelete sql.NullString `db:"on_delete"`
CheckExpr sql.NullString `db:"check_expr"`
}
table constraint info from database
type TableConstraintInfos ¶
type TableConstraintInfos []TableConstraintInfo
func (TableConstraintInfos) ColumnNames ¶
func (t TableConstraintInfos) ColumnNames() []string
Get the column names of the table constraint infos
func (TableConstraintInfos) ForeignColumnNames ¶
func (t TableConstraintInfos) ForeignColumnNames() []string
Get the foreign column names of the table constraint infos
func (TableConstraintInfos) Group ¶
func (t TableConstraintInfos) Group() map[string]map[string]TableConstraintInfos
Group by type and name, return map[type]map[name]TableConstraintInfos
type TableConstraints ¶
type TableConstraints struct {
PrimaryKey constraint.PrimaryKey
ForeignKeys []constraint.ForeignKey
Checks []constraint.Check
Uniques []constraint.Unique
}
func (*TableConstraints) AddChecks ¶
func (t *TableConstraints) AddChecks(checks ...constraint.Check)
func (*TableConstraints) AddForeignKeys ¶
func (t *TableConstraints) AddForeignKeys(keys ...constraint.ForeignKey)
func (*TableConstraints) AddUniques ¶
func (t *TableConstraints) AddUniques(keys ...constraint.Unique)
func (*TableConstraints) HasChecks ¶
func (t *TableConstraints) HasChecks() bool
func (*TableConstraints) HasForeignKeys ¶
func (t *TableConstraints) HasForeignKeys() bool
func (*TableConstraints) HasPrimaryKey ¶
func (t *TableConstraints) HasPrimaryKey() bool
func (*TableConstraints) HashUniques ¶
func (t *TableConstraints) HashUniques() bool
func (*TableConstraints) SetPrimaryKey ¶
func (t *TableConstraints) SetPrimaryKey(key constraint.PrimaryKey)
type TableHandler ¶
type TableHandler func(table *TableSchema)
type TableOption ¶
type TableOption func(column *TableSchema)
type TableSchema ¶
type TableSchema struct {
// contains filtered or unexported fields
}
Table schema implement Table interface
func (*TableSchema) AddCommand ¶
func (t *TableSchema) AddCommand(commands ...TableCommand)
add table command
func (*TableSchema) AddPrimaryKey ¶
func (t *TableSchema) AddPrimaryKey(columnNames ...string)
Add primary keys to the table
func (*TableSchema) AddedColumns ¶
func (t *TableSchema) AddedColumns() []Column
Get the added columns
func (*TableSchema) BigID ¶
func (t *TableSchema) BigID(name string, options ...ColumnOption) *ColumnSchema
BigID Create a new auto-incrementing big integer (8-byte) column on the table.
func (*TableSchema) BigInt ¶
func (t *TableSchema) BigInt(name string, options ...ColumnOption) *ColumnSchema
BigInt Create a new big integer (8-byte) column on the table.
func (*TableSchema) Binary ¶
func (t *TableSchema) Binary(name string, options ...ColumnOption) *ColumnSchema
Binary Create a new binary column on the table.
func (*TableSchema) Boolean ¶
func (t *TableSchema) Boolean(name string, options ...ColumnOption) *ColumnSchema
Boolean Create a new boolean column on the table.
func (*TableSchema) ChangedColumns ¶
func (t *TableSchema) ChangedColumns() []Column
Get the changed columns
func (*TableSchema) Char ¶
func (t *TableSchema) Char(name string, options ...ColumnOption) *ColumnSchema
Char Create a new char column on the table.
func (*TableSchema) Charset ¶
func (t *TableSchema) Charset() string
func (*TableSchema) Collation ¶
func (t *TableSchema) Collation() string
func (*TableSchema) ColumnExists ¶
func (t *TableSchema) ColumnExists(columnName string) bool
whether the column exists of the table
func (*TableSchema) Columns ¶
func (t *TableSchema) Columns() []Column
Columns get all columns of the table
func (*TableSchema) Commands ¶
func (t *TableSchema) Commands() []TableCommand
Commands get all command of the table
func (*TableSchema) Comment ¶
func (t *TableSchema) Comment() string
func (*TableSchema) Date ¶
func (t *TableSchema) Date(name string, options ...ColumnOption) *ColumnSchema
Date Create a new date column on the table.
func (*TableSchema) DateTime ¶
func (t *TableSchema) DateTime(name string, options ...ColumnOption) *ColumnSchema
DateTime Create a new dateTime column on the table.
func (*TableSchema) DateTimeTz ¶
func (t *TableSchema) DateTimeTz(name string, options ...ColumnOption) *ColumnSchema
DateTimeTz Create a new dateTimeTz column on the table.
func (*TableSchema) Decimal ¶
func (t *TableSchema) Decimal(name string, options ...ColumnOption) *ColumnSchema
Boolean Create a new decimal column on the table.
func (*TableSchema) Double ¶
func (t *TableSchema) Double(name string, options ...ColumnOption) *ColumnSchema
Double Create a new double column on the table.
func (*TableSchema) DropColumns ¶
func (t *TableSchema) DropColumns(columnNames ...string)
Modify the column of the table
func (*TableSchema) DropIfExists ¶
func (t *TableSchema) DropIfExists(name string)
Drop the table if exists
func (*TableSchema) DropPrimaryKey ¶
func (t *TableSchema) DropPrimaryKey()
Drop the primary keys of the table
func (*TableSchema) Engine ¶
func (t *TableSchema) Engine() string
func (*TableSchema) Enum ¶
func (t *TableSchema) Enum(name string, options ...ColumnOption) *ColumnSchema
Enum Create a new enum column on the table.
func (*TableSchema) Float ¶
func (t *TableSchema) Float(name string, options ...ColumnOption) *ColumnSchema
Float Create a new float column on the table.
func (*TableSchema) Geometry ¶
func (t *TableSchema) Geometry(name string, options ...ColumnOption) *ColumnSchema
Geometry create a new geometry column on the table.
func (*TableSchema) GeometryCollection ¶
func (t *TableSchema) GeometryCollection(name string, options ...ColumnOption) *ColumnSchema
Geometrycollection create a new geometry collection column on the table.
func (*TableSchema) ID ¶
func (t *TableSchema) ID(name string, options ...ColumnOption) *ColumnSchema
ID Create a new auto-incrementing integer (4-byte) column on the table.
func (*TableSchema) IPAddress ¶
func (t *TableSchema) IPAddress(name string, options ...ColumnOption) *ColumnSchema
IPAddress Create a new IP address column on the table.
func (*TableSchema) Index ¶
func (t *TableSchema) Index(columnNames []string, options ...IndexOptions)
Add a new index to the table.
func (*TableSchema) Int ¶
func (t *TableSchema) Int(name string, options ...ColumnOption) *ColumnSchema
Int Create a new integer (4-byte) column on the table.
func (*TableSchema) IsTemporary ¶
func (t *TableSchema) IsTemporary() bool
func (*TableSchema) Json ¶
func (t *TableSchema) Json(name string, options ...ColumnOption) *ColumnSchema
Json Create a new json column on the table.
func (*TableSchema) Jsonb ¶
func (t *TableSchema) Jsonb(name string, options ...ColumnOption) *ColumnSchema
Jsonb Create a new jsonb column on the table.
func (*TableSchema) LineString ¶
func (t *TableSchema) LineString(name string, options ...ColumnOption) *ColumnSchema
LineString create a new linestring column on the table.
func (*TableSchema) LongText ¶
func (t *TableSchema) LongText(name string, options ...ColumnOption) *ColumnSchema
LongText Create a new long text column on the table.
func (*TableSchema) MacAddress ¶
func (t *TableSchema) MacAddress(name string, options ...ColumnOption) *ColumnSchema
MacAddress create a new MAC address column on the table.
func (*TableSchema) MediumInt ¶
func (t *TableSchema) MediumInt(name string, options ...ColumnOption) *ColumnSchema
MediumInt Create a new medium integer (3-byte) column on the table.
func (*TableSchema) MediumText ¶
func (t *TableSchema) MediumText(name string, options ...ColumnOption) *ColumnSchema
MediumText Create a new medium text column on the table.
func (*TableSchema) Modify ¶
func (t *TableSchema) Modify(columnName string, options ...ColumnOption)
Modify the column of the table
func (*TableSchema) MultiLineString ¶
func (t *TableSchema) MultiLineString(name string, options ...ColumnOption) *ColumnSchema
MultiLineString create a new multilinestring column on the table.
func (*TableSchema) MultiPoint ¶
func (t *TableSchema) MultiPoint(name string, options ...ColumnOption) *ColumnSchema
MultiPoint create a new multipoint column on the table.
func (*TableSchema) MultiPolygon ¶
func (t *TableSchema) MultiPolygon(name string, options ...ColumnOption) *ColumnSchema
MultiPolygon create a new multipolygon column on the table.
func (*TableSchema) MultiPolygonZ ¶
func (t *TableSchema) MultiPolygonZ(name string, options ...ColumnOption) *ColumnSchema
MultiPolygonZ create a new multipolygonz column on the table.
func (*TableSchema) Name ¶
func (t *TableSchema) Name() string
func (*TableSchema) Point ¶
func (t *TableSchema) Point(name string, options ...ColumnOption) *ColumnSchema
Point create a new point column on the table.
func (*TableSchema) Polygon ¶
func (t *TableSchema) Polygon(name string, options ...ColumnOption) *ColumnSchema
Polygon create a new polygon column on the table.
func (*TableSchema) Prefix ¶
func (t *TableSchema) Prefix() string
func (*TableSchema) PrimaryKey ¶
func (t *TableSchema) PrimaryKey() []string
Get the primary keys of the table
func (*TableSchema) RemoveColumn ¶
func (t *TableSchema) RemoveColumn(name string) *TableSchema
Remove a column from columns of the table.
func (*TableSchema) Schema ¶
func (t *TableSchema) Schema() string
func (*TableSchema) Set ¶
func (t *TableSchema) Set(name string, options ...ColumnOption) *ColumnSchema
Set Create a new set column on the table.
func (*TableSchema) SetCharset ¶
func (t *TableSchema) SetCharset(charset string) *TableSchema
set the charset for the table
func (*TableSchema) SetCollation ¶
func (t *TableSchema) SetCollation(collation string) *TableSchema
set the collation for the table
func (*TableSchema) SetComment ¶
func (t *TableSchema) SetComment(comment string) *TableSchema
set the comment for the table
func (*TableSchema) SetEngine ¶
func (t *TableSchema) SetEngine(engine string) *TableSchema
set the engine for the table
func (*TableSchema) SetOptions ¶
func (t *TableSchema) SetOptions(options string) *TableSchema
set the options for the table
func (*TableSchema) SetPrefix ¶
func (t *TableSchema) SetPrefix(prefix string) *TableSchema
set the prefix for the table
func (*TableSchema) SetTemporary ¶
func (t *TableSchema) SetTemporary(temporary bool) *TableSchema
set the temporary for the table
func (*TableSchema) SmallInt ¶
func (t *TableSchema) SmallInt(name string, options ...ColumnOption) *ColumnSchema
SmallInt Create a new small integer (2-byte) column on the table.
func (*TableSchema) SpatialIndex ¶
func (t *TableSchema) SpatialIndex(columnNames []string, options ...IndexOptions)
Add a new spatial index to the table.
func (*TableSchema) String ¶
func (t *TableSchema) String(name string, options ...ColumnOption) *ColumnSchema
String Create a new string column on the table.
func (*TableSchema) Text ¶
func (t *TableSchema) Text(name string, options ...ColumnOption) *ColumnSchema
Text Create a new text column on the table.
func (*TableSchema) Time ¶
func (t *TableSchema) Time(name string, options ...ColumnOption) *ColumnSchema
Time Create a new time column on the table.
func (*TableSchema) TimeTz ¶
func (t *TableSchema) TimeTz(name string, options ...ColumnOption) *ColumnSchema
TimeTz Create a new time column (with time zone) on the table.
func (*TableSchema) Timestamp ¶
func (t *TableSchema) Timestamp(name string, options ...ColumnOption) *ColumnSchema
Timestamp Create a new timestamp column on the table.
func (*TableSchema) TimestampTz ¶
func (t *TableSchema) TimestampTz(name string, options ...ColumnOption) *ColumnSchema
TimestampTz Create a new timestampTz column (with time zone) on the table.
func (*TableSchema) TinyInt ¶
func (t *TableSchema) TinyInt(name string, options ...ColumnOption) *ColumnSchema
TinyInt Create a new tiny integer (1-byte) column on the table.
func (*TableSchema) UUID ¶
func (t *TableSchema) UUID(name string, options ...ColumnOption) *ColumnSchema
UUID Create a new uuid column on the table.
func (*TableSchema) Unique ¶
func (t *TableSchema) Unique(columnNames []string, options ...IndexOptions)
Add a new unique index to the table.
func (*TableSchema) Year ¶
func (t *TableSchema) Year(name string, options ...ColumnOption) *ColumnSchema
Year Create a new year column on the table.