package mysql
Import Path
gorm.io/driver/mysql (on go.dev )
Dependency Relation
imports 16 packages , and imported by one package
Package-Level Type Names (total 4)
/* sort by: alphabet | popularity */
type Migrator (struct)
Fields (total 19 )
Dialector Dialector
Dialector .Config .Conn gorm .ConnPool
Dialector .Config .DSN string
Dialector .Config .DSNConfig *mysql .Config
Dialector .Config .DefaultDatetimePrecision *int
Dialector .Config .DefaultStringSize uint
Dialector .Config .DisableDatetimePrecision bool
Dialector .Config .DisableWithReturning bool
Dialector .Config .DontSupportForShareClause bool
Dialector .Config .DontSupportNullAsDefaultValue bool
Dialector .Config .DontSupportRenameColumn bool
Dialector .Config .DontSupportRenameColumnUnique bool
Dialector .Config .DontSupportRenameIndex bool
Dialector .Config .DriverName string
Dialector .Config .ServerVersion string
Dialector .Config .SkipInitializeWithVersion bool
Migrator migrator .Migrator
Migrator .Config .CreateIndexAfterCreateTable bool
Migrator .Config .DB *gorm .DB
Methods (total 46 )
( Migrator) AddColumn (value interface{}, name string ) error
( Migrator) AlterColumn (value interface{}, field string ) error
( Migrator) Apply (config *gorm .Config ) error
( Migrator) AutoMigrate (values ...interface{}) error
AutoMigrate auto migrate values
( Migrator) BindVarTo (writer clause .Writer , stmt *gorm .Statement , v interface{})
( Migrator) BuildIndexOptions (opts []schema .IndexOption , stmt *gorm .Statement ) (results []interface{})
BuildIndexOptions build index options
( Migrator) ClauseBuilders () map[string ]clause .ClauseBuilder
( Migrator) ColumnTypes (value interface{}) ([]gorm .ColumnType , error )
ColumnTypes column types return columnTypes,error
( Migrator) CreateConstraint (value interface{}, name string ) error
CreateConstraint create constraint
( Migrator) CreateIndex (value interface{}, name string ) error
CreateIndex create index `name`
( Migrator) CreateTable (values ...interface{}) error
CreateTable create table in database for values
( Migrator) CreateView (name string , option gorm .ViewOption ) error
CreateView create view from Query in gorm.ViewOption.
Query in gorm.ViewOption is a [subquery]
// CREATE VIEW `user_view` AS SELECT * FROM `users` WHERE age > 20
q := DB.Model(&User{}).Where("age > ?", 20)
DB.Debug().Migrator().CreateView("user_view", gorm.ViewOption{Query: q})
// CREATE OR REPLACE VIEW `users_view` AS SELECT * FROM `users` WITH CHECK OPTION
q := DB.Model(&User{})
DB.Debug().Migrator().CreateView("user_view", gorm.ViewOption{Query: q, Replace: true, CheckOption: "WITH CHECK OPTION"})
[subquery]: https://gorm.io/docs/advanced_query.html#SubQuery
( Migrator) CurrentDatabase () (name string )
( Migrator) CurrentSchema (stmt *gorm .Statement , table string ) (string , string )
( Migrator) CurrentTable (stmt *gorm .Statement ) interface{}
CurrentTable returns current statement's table expression
( Migrator) DefaultValueOf (field *schema .Field ) clause .Expression
( Migrator) DropColumn (value interface{}, name string ) error
DropColumn drop value's `name` column
( Migrator) DropConstraint (value interface{}, name string ) error
( Migrator) DropIndex (value interface{}, name string ) error
DropIndex drop index `name`
( Migrator) DropTable (values ...interface{}) error
( Migrator) DropView (name string ) error
DropView drop view
( Migrator) Explain (sql string , vars ...interface{}) string
( Migrator) FullDataTypeOf (field *schema .Field ) clause .Expr
( Migrator) GetIndexes (value interface{}) ([]gorm .Index , error )
( Migrator) GetTables () (tableList []string , err error )
( Migrator) GetTypeAliases (databaseTypeName string ) []string
( Migrator) GuessConstraintAndTable (stmt *gorm .Statement , name string ) (_ *schema .Constraint , _ *schema .Check , table string )
GuessConstraintAndTable guess statement's constraint and it's table based on name
( Migrator) HasColumn (value interface{}, field string ) bool
HasColumn check has column `field` for value or not
( Migrator) HasConstraint (value interface{}, name string ) bool
HasConstraint check has constraint or not
( Migrator) HasIndex (value interface{}, name string ) bool
HasIndex check has index `name` or not
( Migrator) HasTable (value interface{}) bool
HasTable returns table exists or not for value, value could be a struct or string
( Migrator) Initialize (db *gorm .DB ) (err error )
( Migrator) MigrateColumn (value interface{}, field *schema .Field , columnType gorm .ColumnType ) error
MigrateColumn migrate column
( Migrator) Name () string
( Migrator) NowFunc (n int ) func() time .Time
NowFunc return now func
( Migrator) QuoteTo (writer clause .Writer , str string )
( Migrator) RenameColumn (value interface{}, oldName, newName string ) error
( Migrator) RenameIndex (value interface{}, oldName, newName string ) error
( Migrator) RenameTable (oldName, newName interface{}) error
RenameTable rename table from oldName to newName
( Migrator) ReorderModels (values []interface{}, autoAdd bool ) (results []interface{})
ReorderModels reorder models according to constraint dependencies
( Migrator) RollbackTo (tx *gorm .DB , name string ) error
( Migrator) RunWithValue (value interface{}, fc func(*gorm .Statement ) error ) error
RunWithValue run migration with statement value
( Migrator) SavePoint (tx *gorm .DB , name string ) error
( Migrator) TableType (value interface{}) (tableType gorm .TableType , err error )
TableType table type return tableType,error
( Migrator) TiDBVersion () (isTiDB bool , major, minor, patch int , err error )
( Migrator) Translate (err error ) error
Implements (at least 5 )
Migrator : gorm.io/gorm.ErrorTranslator
Migrator : gorm.io/gorm.Migrator
Migrator : gorm.io/gorm.Plugin
Migrator : gorm.io/gorm.SavePointerDialectorInterface
Migrator : gorm.io/gorm/migrator.BuildIndexOptionsInterface
Package-Level Functions (total 2)
Package-Level Variables (total 4)
Package-Level Constants (total 4)
const AutoRandomTag = "auto_random()" // Treated as an auto_random field for tidb
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .