MCPcopy Index your code
hub / github.com/apache/devlake / AllTables

Method AllTables

backend/impls/dalgorm/dalgorm.go:394–413  ·  view source on GitHub ↗

AllTables returns all tables in the database

()

Source from the content-addressed store, hash-verified

392
393// AllTables returns all tables in the database
394func (d *Dalgorm) AllTables() ([]string, errors.Error) {
395 var tableSql string
396 if d.db.Dialector.Name() == "mysql" {
397 tableSql = "show tables"
398 } else {
399 tableSql = "select table_name from information_schema.tables where table_schema = 'public' and table_name not like '_devlake%'"
400 }
401 var tables []string
402 err := d.db.Raw(tableSql).Scan(&tables).Error
403 if err != nil {
404 return nil, d.convertGormError(err)
405 }
406 var filteredTables []string
407 for _, table := range tables {
408 if !strings.HasPrefix(table, "_devlake") {
409 filteredTables = append(filteredTables, table)
410 }
411 }
412 return filteredTables, nil
413}
414
415// DropTables drop multiple tables by Model Pointer or Table Name
416func (d *Dalgorm) DropTables(dst ...interface{}) errors.Error {

Callers

nothing calls this directly

Calls 3

convertGormErrorMethod · 0.95
NameMethod · 0.65
ScanMethod · 0.65

Tested by

no test coverage detected