Documentation ¶
Index ¶
- func CleanMigration()
- func Create(tableName string, fields ...func(table *MigrationTable))
- func Drop(tableName string)
- func DropIfExists(tableName string)
- func Fresh()
- func Migrate(force ...bool)
- func ReName(tableName string, newName string)
- func RegisterMigration(migrationFunc migrationer, version string)
- func RegisterSqlDrive(t *sql.Tx)
- func RollBack(step ...int)
- func RollBackAndMigrate(step ...int)
- func UpdateTable(tableName string, fields ...func(table *MigrationTable))
- type ForeignAttributes
- type MigrationAttribute
- type MigrationAttributes
- func (m *MigrationAttributes) Change()
- func (m *MigrationAttributes) Comment(c ...string)
- func (m *MigrationAttributes) Default(d interface{}) *MigrationAttributes
- func (m *MigrationAttributes) DefaultNow() *MigrationAttributes
- func (m *MigrationAttributes) Index(indexName string) *MigrationAttributes
- func (m *MigrationAttributes) NullTable(isNull bool) *MigrationAttributes
- func (m *MigrationAttributes) PrimaryKey() *MigrationAttributes
- type MigrationForegion
- type MigrationTable
- func (m *MigrationTable) BigIncrements(field string) *MigrationAttributes
- func (m *MigrationTable) BigInteger(field string) *MigrationAttributes
- func (m *MigrationTable) Binary(field string) *MigrationAttributes
- func (m *MigrationTable) Boolean(field string) *MigrationAttributes
- func (m *MigrationTable) Char(field string, length ...int) *MigrationAttributes
- func (m *MigrationTable) Charset(charset string)
- func (m *MigrationTable) Collation(collation string)
- func (m *MigrationTable) Comment(field string) *MigrationAttributes
- func (m *MigrationTable) Date(field string) *MigrationAttributes
- func (m *MigrationTable) DateTime(field string) *MigrationAttributes
- func (m *MigrationTable) Decimal(field string, length int, precision int) *MigrationAttributes
- func (m *MigrationTable) Double(field string, length int, precision int) *MigrationAttributes
- func (m *MigrationTable) DropField(fields ...string)
- func (m *MigrationTable) DropIndex(name string)
- func (m *MigrationTable) DropPrimary(name string)
- func (m *MigrationTable) DropSpatialIndex(name string)
- func (m *MigrationTable) DropUnique(name string)
- func (m *MigrationTable) Engine(engine string)
- func (m *MigrationTable) Float(field string, length int, precision int) *MigrationAttributes
- func (m *MigrationTable) Foreign(key string) *ForeignAttributes
- func (m *MigrationTable) Geometry(field string) *MigrationAttributes
- func (m *MigrationTable) GeometryCollection(field string) *MigrationAttributes
- func (m *MigrationTable) Increments(field string) *MigrationAttributes
- func (m *MigrationTable) Index(indexName string, fields ...string)
- func (m *MigrationTable) Integer(field string) *MigrationAttributes
- func (m *MigrationTable) Json(field string) *MigrationAttributes
- func (m *MigrationTable) LineString(field string) *MigrationAttributes
- func (m *MigrationTable) LongText(field string) *MigrationAttributes
- func (m *MigrationTable) MediumIncrements(field string) *MigrationAttributes
- func (m *MigrationTable) MediumInteger(field string) *MigrationAttributes
- func (m *MigrationTable) MediumText(field string) *MigrationAttributes
- func (m *MigrationTable) MultiLineString(field string) *MigrationAttributes
- func (m *MigrationTable) MultiPoint(field string) *MigrationAttributes
- func (m *MigrationTable) MultiPolygon(field string) *MigrationAttributes
- func (m *MigrationTable) Point(field string) *MigrationAttributes
- func (m *MigrationTable) Polygon(field string) *MigrationAttributes
- func (m *MigrationTable) RenameField(field string, newField string)
- func (m *MigrationTable) RenameIndex(indexName, newName string)
- func (m *MigrationTable) SmallIncrements(field string) *MigrationAttributes
- func (m *MigrationTable) SmallInteger(field string) *MigrationAttributes
- func (m *MigrationTable) SoftDeletes() *MigrationAttributes
- func (m *MigrationTable) SpatialIndex(name string, fields ...string)
- func (m *MigrationTable) String(field string, length ...int) *MigrationAttributes
- func (m *MigrationTable) Temporary()
- func (m *MigrationTable) Text(field string) *MigrationAttributes
- func (m *MigrationTable) Time(field string) *MigrationAttributes
- func (m *MigrationTable) Timestamp(field string) *MigrationAttributes
- func (m *MigrationTable) Timestamps() *MigrationAttributes
- func (m *MigrationTable) TinyInteger(field string) *MigrationAttributes
- func (m *MigrationTable) Unique(name string, fields ...string)
- func (m *MigrationTable) UnsignedBigInteger(field string) *MigrationAttributes
- func (m *MigrationTable) UnsignedDecimal(field string, length, precision int) *MigrationAttributes
- func (m *MigrationTable) UnsignedInteger(field string) *MigrationAttributes
- func (m *MigrationTable) UnsignedMediumInteger(field string) *MigrationAttributes
- func (m *MigrationTable) UnsignedSmallInteger(field string) *MigrationAttributes
- func (m *MigrationTable) UnsignedTinyInteger(field string) *MigrationAttributes
- func (m *MigrationTable) Year(field string) *MigrationAttributes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanMigration ¶
func CleanMigration()
CleanMigration Clean up funcs that are permanently up/down in memory 清理在初始化时常驻在内存中的 up/down 方法
func Create ¶
func Create(tableName string, fields ...func(table *MigrationTable))
*
- @Description:
- @param tableName
- @param version
- @param fields
- @auth: daguang
func DropIfExists ¶
func DropIfExists(tableName string)
*
- @Description:
- @param tableName
- @auth: daguang
func RegisterMigration ¶
func RegisterMigration(migrationFunc migrationer, version string)
RegisterMigration All migration methods are registered with Slice during initialization 初始化时将全部迁移的 UP/DOWN 方法添加到 slice 和对应的 map 中
func RegisterSqlDrive ¶
func UpdateTable ¶
func UpdateTable(tableName string, fields ...func(table *MigrationTable))
*
- @Description:
- @param tableName
- @param version
- @param fields
- @auth: daguang
Types ¶
type ForeignAttributes ¶
type ForeignAttributes struct {
// contains filtered or unexported fields
}
func (*ForeignAttributes) OnDelete ¶
func (m *ForeignAttributes) OnDelete() *ForeignAttributes
func (*ForeignAttributes) OnUpdate ¶
func (m *ForeignAttributes) OnUpdate() *ForeignAttributes
func (*ForeignAttributes) References ¶
func (m *ForeignAttributes) References(table, field string) *ForeignAttributes
type MigrationAttribute ¶
type MigrationAttribute struct {
// contains filtered or unexported fields
}
type MigrationAttributes ¶
type MigrationAttributes struct {
// contains filtered or unexported fields
}
func (*MigrationAttributes) Change ¶
func (m *MigrationAttributes) Change()
func (*MigrationAttributes) Comment ¶
func (m *MigrationAttributes) Comment(c ...string)
func (*MigrationAttributes) Default ¶
func (m *MigrationAttributes) Default(d interface{}) *MigrationAttributes
func (*MigrationAttributes) DefaultNow ¶
func (m *MigrationAttributes) DefaultNow() *MigrationAttributes
func (*MigrationAttributes) Index ¶
func (m *MigrationAttributes) Index(indexName string) *MigrationAttributes
Index 添加一个单独的 index
func (*MigrationAttributes) NullTable ¶
func (m *MigrationAttributes) NullTable(isNull bool) *MigrationAttributes
func (*MigrationAttributes) PrimaryKey ¶
func (m *MigrationAttributes) PrimaryKey() *MigrationAttributes
type MigrationForegion ¶
type MigrationForegion struct {
// contains filtered or unexported fields
}
type MigrationTable ¶
type MigrationTable struct {
// contains filtered or unexported fields
}
func (*MigrationTable) BigIncrements ¶
func (m *MigrationTable) BigIncrements(field string) *MigrationAttributes
*
- @Description: 递增 ID(主键),相当于「UNSIGNED BIG INTEGER」
- @receiver m
- @param field
- @auth: daguang
- @return *MigrationAttributes
func (*MigrationTable) BigInteger ¶
func (m *MigrationTable) BigInteger(field string) *MigrationAttributes
*
- @Description: 相当于 BIGINT
- @receiver m
- @param field
- @auth: daguang
- @return *MigrationAttributes
func (*MigrationTable) Binary ¶
func (m *MigrationTable) Binary(field string) *MigrationAttributes
*
- @Description: 相当于 BLOB
- @receiver m
- @param field
- @auth: daguang
- @return *MigrationAttributes
func (*MigrationTable) Boolean ¶
func (m *MigrationTable) Boolean(field string) *MigrationAttributes
*
- @Description:
- @receiver m
- @param field
- @auth: daguang
- @return *MigrationAttributes
func (*MigrationTable) Char ¶
func (m *MigrationTable) Char(field string, length ...int) *MigrationAttributes
*
- @Description: 相当于带有长度的 CHAR
- @receiver m
- @param field
- @param length
- @auth: daguang
- @return *MigrationAttributes
func (*MigrationTable) Charset ¶
func (m *MigrationTable) Charset(charset string)
func (*MigrationTable) Collation ¶
func (m *MigrationTable) Collation(collation string)
func (*MigrationTable) Comment ¶
func (m *MigrationTable) Comment(field string) *MigrationAttributes
Comment 表注释
func (*MigrationTable) Date ¶
func (m *MigrationTable) Date(field string) *MigrationAttributes
func (*MigrationTable) DateTime ¶
func (m *MigrationTable) DateTime(field string) *MigrationAttributes
func (*MigrationTable) Decimal ¶
func (m *MigrationTable) Decimal(field string, length int, precision int) *MigrationAttributes
func (*MigrationTable) Double ¶
func (m *MigrationTable) Double(field string, length int, precision int) *MigrationAttributes
func (*MigrationTable) DropField ¶
func (m *MigrationTable) DropField(fields ...string)
*
- @Description: 删除字段
- @receiver m
- @param fields
- @auth: daguang
func (*MigrationTable) DropIndex ¶
func (m *MigrationTable) DropIndex(name string)
func (*MigrationTable) DropPrimary ¶
func (m *MigrationTable) DropPrimary(name string)
func (*MigrationTable) DropSpatialIndex ¶
func (m *MigrationTable) DropSpatialIndex(name string)
func (*MigrationTable) DropUnique ¶
func (m *MigrationTable) DropUnique(name string)
func (*MigrationTable) Engine ¶
func (m *MigrationTable) Engine(engine string)
func (*MigrationTable) Float ¶
func (m *MigrationTable) Float(field string, length int, precision int) *MigrationAttributes
func (*MigrationTable) Foreign ¶
func (m *MigrationTable) Foreign(key string) *ForeignAttributes
func (*MigrationTable) Geometry ¶
func (m *MigrationTable) Geometry(field string) *MigrationAttributes
func (*MigrationTable) GeometryCollection ¶
func (m *MigrationTable) GeometryCollection(field string) *MigrationAttributes
func (*MigrationTable) Increments ¶
func (m *MigrationTable) Increments(field string) *MigrationAttributes
*
- @Description: 递增的 ID (主键),相当于「UNSIGNED INTEGER」
- @receiver m
- @param field
- @auth: daguang
- @return *MigrationAttributes
func (*MigrationTable) Index ¶
func (m *MigrationTable) Index(indexName string, fields ...string)
func (*MigrationTable) Integer ¶
func (m *MigrationTable) Integer(field string) *MigrationAttributes
func (*MigrationTable) Json ¶
func (m *MigrationTable) Json(field string) *MigrationAttributes
func (*MigrationTable) LineString ¶
func (m *MigrationTable) LineString(field string) *MigrationAttributes
func (*MigrationTable) LongText ¶
func (m *MigrationTable) LongText(field string) *MigrationAttributes
func (*MigrationTable) MediumIncrements ¶
func (m *MigrationTable) MediumIncrements(field string) *MigrationAttributes
*
- @Description: 递增 ID (主键) ,相当于「UNSIGNED MEDIUM INTEGER」
- @receiver m
- @param field
- @auth: daguang
- @return *MigrationAttributes
func (*MigrationTable) MediumInteger ¶
func (m *MigrationTable) MediumInteger(field string) *MigrationAttributes
func (*MigrationTable) MediumText ¶
func (m *MigrationTable) MediumText(field string) *MigrationAttributes
func (*MigrationTable) MultiLineString ¶
func (m *MigrationTable) MultiLineString(field string) *MigrationAttributes
func (*MigrationTable) MultiPoint ¶
func (m *MigrationTable) MultiPoint(field string) *MigrationAttributes
func (*MigrationTable) MultiPolygon ¶
func (m *MigrationTable) MultiPolygon(field string) *MigrationAttributes
func (*MigrationTable) Point ¶
func (m *MigrationTable) Point(field string) *MigrationAttributes
func (*MigrationTable) Polygon ¶
func (m *MigrationTable) Polygon(field string) *MigrationAttributes
func (*MigrationTable) RenameField ¶
func (m *MigrationTable) RenameField(field string, newField string)
*
- @Description: 字段重命名
- @receiver m
- @param field
- @param newField
- @auth: daguang
func (*MigrationTable) RenameIndex ¶
func (m *MigrationTable) RenameIndex(indexName, newName string)
func (*MigrationTable) SmallIncrements ¶
func (m *MigrationTable) SmallIncrements(field string) *MigrationAttributes
*
- @Description: 递增 ID (主键) ,相当于「UNSIGNED SMALL INTEGER」
- @receiver m
- @param field
- @auth: daguang
- @return *MigrationAttributes
func (*MigrationTable) SmallInteger ¶
func (m *MigrationTable) SmallInteger(field string) *MigrationAttributes
func (*MigrationTable) SoftDeletes ¶
func (m *MigrationTable) SoftDeletes() *MigrationAttributes
*
- @Description: 相当于为软删除添加一个可空的 deleted_at 字段
- @receiver m
- @auth: daguang
- @return *MigrationAttributes
func (*MigrationTable) SpatialIndex ¶
func (m *MigrationTable) SpatialIndex(name string, fields ...string)
func (*MigrationTable) String ¶
func (m *MigrationTable) String(field string, length ...int) *MigrationAttributes
func (*MigrationTable) Temporary ¶
func (m *MigrationTable) Temporary()
func (*MigrationTable) Text ¶
func (m *MigrationTable) Text(field string) *MigrationAttributes
func (*MigrationTable) Time ¶
func (m *MigrationTable) Time(field string) *MigrationAttributes
func (*MigrationTable) Timestamp ¶
func (m *MigrationTable) Timestamp(field string) *MigrationAttributes
func (*MigrationTable) Timestamps ¶
func (m *MigrationTable) Timestamps() *MigrationAttributes
生成可以由框架自动维护的 create_at 与 update_at
func (*MigrationTable) TinyInteger ¶
func (m *MigrationTable) TinyInteger(field string) *MigrationAttributes
func (*MigrationTable) Unique ¶
func (m *MigrationTable) Unique(name string, fields ...string)
func (*MigrationTable) UnsignedBigInteger ¶
func (m *MigrationTable) UnsignedBigInteger(field string) *MigrationAttributes
func (*MigrationTable) UnsignedDecimal ¶
func (m *MigrationTable) UnsignedDecimal(field string, length, precision int) *MigrationAttributes
func (*MigrationTable) UnsignedInteger ¶
func (m *MigrationTable) UnsignedInteger(field string) *MigrationAttributes
func (*MigrationTable) UnsignedMediumInteger ¶
func (m *MigrationTable) UnsignedMediumInteger(field string) *MigrationAttributes
func (*MigrationTable) UnsignedSmallInteger ¶
func (m *MigrationTable) UnsignedSmallInteger(field string) *MigrationAttributes
func (*MigrationTable) UnsignedTinyInteger ¶
func (m *MigrationTable) UnsignedTinyInteger(field string) *MigrationAttributes
func (*MigrationTable) Year ¶
func (m *MigrationTable) Year(field string) *MigrationAttributes
Source Files ¶
Click to show internal directories.
Click to hide internal directories.