importDatabaseBackup will import a slice of downloaded databases If a custom importer is provided, that will be used, otherwise the default is app.ImportDB()
(fileLocation []string, importPath []string)
| 379 | // If a custom importer is provided, that will be used, otherwise |
| 380 | // the default is app.ImportDB() |
| 381 | func (p *Provider) importDatabaseBackup(fileLocation []string, importPath []string) error { |
| 382 | var err error |
| 383 | if p.DBImportCommand.Command == "" { |
| 384 | for i, loc := range fileLocation { |
| 385 | // The database name used will be basename of the file. |
| 386 | // For example. `db.sql.gz` will go into the database named 'db' |
| 387 | // xxx.sql will go into database named 'xxx'; |
| 388 | b := path.Base(loc) |
| 389 | n := strings.Split(b, ".") |
| 390 | dbName := n[0] |
| 391 | err = p.app.ImportDB(loc, importPath[i], true, false, dbName) |
| 392 | } |
| 393 | } else { |
| 394 | s := p.DBImportCommand.Service |
| 395 | if s == "" { |
| 396 | s = "web" |
| 397 | } |
| 398 | output.UserOut.Printf("Importing database via custom db_import_command") |
| 399 | err = p.app.ExecOnHostOrService(s, p.injectedEnvironment()+"; "+p.DBImportCommand.Command) |
| 400 | } |
| 401 | return err |
| 402 | } |
| 403 | |
| 404 | // doFilesImport will import previously downloaded files tarball or directory |
| 405 | // If a custom importer (FileImportCommand) is provided, that will be used, otherwise |
no test coverage detected