HasTable returns table exists or not for value, value could be a struct or string
(value interface{})
| 332 | |
| 333 | // HasTable returns table exists or not for value, value could be a struct or string |
| 334 | func (m Migrator) HasTable(value interface{}) bool { |
| 335 | var count int64 |
| 336 | |
| 337 | m.RunWithValue(value, func(stmt *gorm.Statement) error { |
| 338 | currentDatabase := m.DB.Migrator().CurrentDatabase() |
| 339 | return m.DB.Raw("SELECT count(*) FROM information_schema.tables WHERE table_schema = ? AND table_name = ? AND table_type = ?", currentDatabase, stmt.Table, "BASE TABLE").Row().Scan(&count) |
| 340 | }) |
| 341 | |
| 342 | return count > 0 |
| 343 | } |
| 344 | |
| 345 | // RenameTable rename table from oldName to newName |
| 346 | func (m Migrator) RenameTable(oldName, newName interface{}) error { |
nothing calls this directly
no test coverage detected