Truncate truncates the DB
(db *sqlx.DB)
| 90 | |
| 91 | // Truncate truncates the DB |
| 92 | func Truncate(db *sqlx.DB) { |
| 93 | var sql []string |
| 94 | switch db.DriverName() { |
| 95 | case "mysql": |
| 96 | sql = strings.Split(mysqlTruncateTables, "\n") |
| 97 | case "postgres": |
| 98 | sql = []string{pgTruncateTables} |
| 99 | case "sqlite3": |
| 100 | sql = []string{sqliteTruncateTables} |
| 101 | default: |
| 102 | panic("Unknown driver") |
| 103 | } |
| 104 | |
| 105 | for _, expr := range sql { |
| 106 | if len(strings.TrimSpace(expr)) == 0 { |
| 107 | continue |
| 108 | } |
| 109 | if _, err := db.Exec(expr); err != nil { |
| 110 | panic(err) |
| 111 | } |
| 112 | } |
| 113 | } |
no outgoing calls
searching dependent graphs…