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

Method DropTable

migrator/migrator.go:320–331  ·  view source on GitHub ↗

DropTable drop table for values

(values ...interface{})

Source from the content-addressed store, hash-verified

318
319// DropTable drop table for values
320func (m Migrator) DropTable(values ...interface{}) error {
321 values = m.ReorderModels(values, false)
322 for i := len(values) - 1; i >= 0; i-- {
323 tx := m.DB.Session(&gorm.Session{})
324 if err := m.RunWithValue(values[i], func(stmt *gorm.Statement) error {
325 return tx.Exec("DROP TABLE IF EXISTS ?", m.CurrentTable(stmt)).Error
326 }); err != nil {
327 return err
328 }
329 }
330 return nil
331}
332
333// HasTable returns table exists or not for value, value could be a struct or string
334func (m Migrator) HasTable(value interface{}) bool {

Callers

nothing calls this directly

Implementers 1

Migratormigrator/migrator.go

Calls 5

ReorderModelsMethod · 0.95
RunWithValueMethod · 0.95
CurrentTableMethod · 0.95
SessionMethod · 0.80
ExecMethod · 0.65

Tested by

no test coverage detected