MCPcopy
hub / github.com/go-gorp/gorp / DropIndex

Method DropIndex

db.go:181–203  ·  view source on GitHub ↗
(name string)

Source from the content-addressed store, hash-verified

179}
180
181func (t *TableMap) DropIndex(name string) error {
182
183 var err error
184 dialect := reflect.TypeOf(t.dbmap.Dialect)
185 for _, idx := range t.indexes {
186 if idx.IndexName == name {
187 s := bytes.Buffer{}
188 s.WriteString(fmt.Sprintf("DROP INDEX %s", idx.IndexName))
189
190 if dname := dialect.Name(); dname == "MySQLDialect" {
191 s.WriteString(fmt.Sprintf(" %s %s", t.dbmap.Dialect.DropIndexSuffix(), t.TableName))
192 }
193 s.WriteString(";")
194 _, e := t.dbmap.Exec(s.String())
195 if e != nil {
196 err = e
197 }
198 break
199 }
200 }
201 t.ResetSql()
202 return err
203}
204
205// AddTable registers the given interface type with gorp. The table name
206// will be given the name of the TypeOf(i). You must call this function,

Callers

nothing calls this directly

Calls 3

ResetSqlMethod · 0.95
DropIndexSuffixMethod · 0.65
ExecMethod · 0.65

Tested by

no test coverage detected