MCPcopy
hub / github.com/go-gorm/gorm / RunWithValue

Method RunWithValue

migrator/migrator.go:62–76  ·  view source on GitHub ↗

RunWithValue run migration with statement value

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

Source from the content-addressed store, hash-verified

60
61// RunWithValue run migration with statement value
62func (m Migrator) RunWithValue(value interface{}, fc func(*gorm.Statement) error) error {
63 stmt := &gorm.Statement{DB: m.DB}
64 if m.DB.Statement != nil {
65 stmt.Table = m.DB.Statement.Table
66 stmt.TableExpr = m.DB.Statement.TableExpr
67 }
68
69 if table, ok := value.(string); ok {
70 stmt.Table = table
71 } else if err := stmt.ParseWithSpecialTableName(value, stmt.Table); err != nil {
72 return err
73 }
74
75 return fc(stmt)
76}
77
78// DataTypeOf return field's db data type
79func (m Migrator) DataTypeOf(field *schema.Field) string {

Callers 15

AutoMigrateMethod · 0.95
CreateTableMethod · 0.95
DropTableMethod · 0.95
HasTableMethod · 0.95
AddColumnMethod · 0.95
DropColumnMethod · 0.95
AlterColumnMethod · 0.95
HasColumnMethod · 0.95
RenameColumnMethod · 0.95
MigrateColumnUniqueMethod · 0.95
ColumnTypesMethod · 0.95
CreateConstraintMethod · 0.95

Implementers 1

Migratormigrator/migrator.go

Calls 1

Tested by

no test coverage detected