添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
func (ct ColumnType) AutoIncrement() (isAutoIncrement bool, ok bool) func (ct ColumnType) ColumnType() (columnType string, ok bool) func (ct ColumnType) Comment() (value string, ok bool) func (ct ColumnType) DatabaseTypeName() string func (ct ColumnType) DecimalSize() (precision int64, scale int64, ok bool) func (ct ColumnType) DefaultValue() (value string, ok bool) func (ct ColumnType) Length() (length int64, ok bool) func (ct ColumnType) Name() string func (ct ColumnType) Nullable() (nullable bool, ok bool) func (ct ColumnType) PrimaryKey() (isPrimaryKey bool, ok bool) func (ct ColumnType) ScanType() reflect.Type func (ct ColumnType) Unique() (unique bool, ok bool) type Config type GormDataTypeInterface type Index func (idx Index) Columns() []string func (idx Index) Name() string func (idx Index) Option() string func (idx Index) PrimaryKey() (isPrimaryKey bool, ok bool) func (idx Index) Table() string func (idx Index) Unique() (unique bool, ok bool) type Migrator func (m Migrator) AddColumn(value interface{}, name string) error func (m Migrator) AlterColumn(value interface{}, field string) error func (m Migrator) AutoMigrate(values ...interface{}) error func (m Migrator) BuildIndexOptions(opts []schema.IndexOption, stmt *gorm.Statement) (results []interface{}) func (m Migrator) ColumnTypes(value interface{}) ([]gorm.ColumnType, error) func (m Migrator) CreateConstraint(value interface{}, name string) error func (m Migrator) CreateIndex(value interface{}, name string) error func (m Migrator) CreateTable(values ...interface{}) error func (m Migrator) CreateView(name string, option gorm.ViewOption) error func (m Migrator) CurrentDatabase() (name string) func (m Migrator) CurrentTable(stmt *gorm.Statement) interface{} func (m Migrator) DataTypeOf(field *schema.Field) string func (m Migrator) DropColumn(value interface{}, name string) error func (m Migrator) DropConstraint(value interface{}, name string) error func (m Migrator) DropIndex(value interface{}, name string) error func (m Migrator) DropTable(values ...interface{}) error func (m Migrator) DropView(name string) error func (m Migrator) FullDataTypeOf(field *schema.Field) (expr clause.Expr) func (m Migrator) GetIndexes(dst interface{}) ([]gorm.Index, error) func (m Migrator) GetQueryAndExecTx() (queryTx, execTx *gorm.DB) func (m Migrator) GetTables() (tableList []string, err error) func (m Migrator) GetTypeAliases(databaseTypeName string) []string func (m Migrator) GuessConstraintAndTable(stmt *gorm.Statement, name string) (*schema.Constraint, *schema.CheckConstraint, string) deprecated func (m Migrator) GuessConstraintInterfaceAndTable(stmt *gorm.Statement, name string) (_ schema.ConstraintInterface, table string) func (m Migrator) HasColumn(value interface{}, field string) bool func (m Migrator) HasConstraint(value interface{}, name string) bool func (m Migrator) HasIndex(value interface{}, name string) bool func (m Migrator) HasTable(value interface{}) bool func (m Migrator) MigrateColumn(value interface{}, field *schema.Field, columnType gorm.ColumnType) error func (m Migrator) MigrateColumnUnique(value interface{}, field *schema.Field, columnType gorm.ColumnType) error func (m Migrator) RenameColumn(value interface{}, oldName, newName string) error func (m Migrator) RenameIndex(value interface{}, oldName, newName string) error func (m Migrator) RenameTable(oldName, newName interface{}) error func (m Migrator) ReorderModels(values []interface{}, autoAdd bool) (results []interface{}) func (m Migrator) RunWithValue(value interface{}, fc func(*gorm.Statement) error) error func (m Migrator) TableType(dst interface{}) (gorm.TableType, error) type TableType func (ct TableType) Comment() (comment string, ok bool) func (ct TableType) Name() string func (ct TableType) Schema() string func (ct TableType) Type() string

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildIndexOptionsInterface interface {
	BuildIndexOptions([]schema.IndexOption, *gorm.Statement) []interface{}
  

BuildIndexOptionsInterface build index options interface SQLColumnType *sql.ColumnType NameValue sql.NullString DataTypeValue sql.NullString ColumnTypeValue sql.NullString PrimaryKeyValue sql.NullBool UniqueValue sql.NullBool AutoIncrementValue sql.NullBool LengthValue sql.NullInt64 DecimalSizeValue sql.NullInt64 ScaleValue sql.NullInt64 NullableValue sql.NullBool ScanTypeValue reflect.Type CommentValue sql.NullString DefaultValueValue sql.NullString

ColumnType column type implements ColumnType interface

func (ct ColumnType) DatabaseTypeName() string

DatabaseTypeName returns the database system name of the column type. If an empty string is returned, then the driver type name is not supported. Consult your driver documentation for a list of driver data types. Length specifiers are not included. Common type names include "VARCHAR", "TEXT", "NVARCHAR", "DECIMAL", "BOOL", "INT", and "BIGINT".

type Config struct {
	CreateIndexAfterCreateTable bool
	DB                          *gorm.DB
	gorm.Dialector
  

Config schema config

type GormDataTypeInterface interface {
	GormDBDataType(*gorm.DB, *schema.Field) string
  

GormDataTypeInterface gorm data type interface

func (m Migrator) BuildIndexOptions(opts []schema.IndexOption, stmt *gorm.Statement) (results []interface{})

BuildIndexOptions build index options

func (m 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"})
      
func (m Migrator) GuessConstraintAndTable(stmt *gorm.Statement, name string) (*schema.Constraint, *schema.CheckConstraint, string)

GuessConstraintAndTable guess statement's constraint and it's table based on name

Deprecated: use GuessConstraintInterfaceAndTable instead.

func (m Migrator) GuessConstraintInterfaceAndTable(stmt *gorm.Statement, name string) (_ schema.ConstraintInterface, table string)

GuessConstraintInterfaceAndTable guess statement's constraint and it's table based on name nolint:cyclop

func (m Migrator) MigrateColumn(value interface{}, field *schema.Field, columnType gorm.ColumnType) error

MigrateColumn migrate column

func (m Migrator) ReorderModels(values []interface{}, autoAdd bool) (results []interface{})

ReorderModels reorder models according to constraint dependencies

func (m Migrator) RunWithValue(value interface{}, fc func(*gorm.Statement) error) error

RunWithValue run migration with statement value

go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic. Learn more.