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

Method DropConstraint

migrator/migrator.go:778–786  ·  view source on GitHub ↗

DropConstraint drop constraint

(value interface{}, name string)

Source from the content-addressed store, hash-verified

776
777// DropConstraint drop constraint
778func (m Migrator) DropConstraint(value interface{}, name string) error {
779 return m.RunWithValue(value, func(stmt *gorm.Statement) error {
780 constraint, table := m.GuessConstraintInterfaceAndTable(stmt, name)
781 if constraint != nil {
782 name = constraint.GetName()
783 }
784 return m.DB.Exec("ALTER TABLE ? DROP CONSTRAINT ?", clause.Table{Name: table}, clause.Column{Name: name}).Error
785 })
786}
787
788// HasConstraint check has constraint or not
789func (m Migrator) HasConstraint(value interface{}, name string) bool {

Callers

nothing calls this directly

Implementers 1

Migratormigrator/migrator.go

Calls 4

RunWithValueMethod · 0.95
GetNameMethod · 0.65
ExecMethod · 0.65

Tested by

no test coverage detected