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

Method DropColumn

migrator/migrator.go:397–409  ·  view source on GitHub ↗

DropColumn drop value's `name` column

(value interface{}, name string)

Source from the content-addressed store, hash-verified

395
396// DropColumn drop value's `name` column
397func (m Migrator) DropColumn(value interface{}, name string) error {
398 return m.RunWithValue(value, func(stmt *gorm.Statement) error {
399 if stmt.Schema != nil {
400 if field := stmt.Schema.LookUpField(name); field != nil {
401 name = field.DBName
402 }
403 }
404
405 return m.DB.Exec(
406 "ALTER TABLE ? DROP COLUMN ?", m.CurrentTable(stmt), clause.Column{Name: name},
407 ).Error
408 })
409}
410
411// AlterColumn alter value's `field` column's type based on schema definition
412func (m Migrator) AlterColumn(value interface{}, field string) error {

Callers

nothing calls this directly

Implementers 1

Migratormigrator/migrator.go

Calls 4

RunWithValueMethod · 0.95
CurrentTableMethod · 0.95
LookUpFieldMethod · 0.80
ExecMethod · 0.65

Tested by

no test coverage detected