cli: allow for schema specification when using hasura seeds create (close #5711) (#5710)

https://github.com/hasura/graphql-engine/pull/5710
This commit is contained in:
Nuno Pato 2020-10-01 13:05:36 +00:00 committed by GitHub
parent 09d0d58436
commit c348ea7a9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,6 +12,7 @@ import (
"fmt"
"io"
"os"
"strings"
"sync"
"text/tabwriter"
"time"
@ -1849,9 +1850,22 @@ func (m *Migrate) ApplySeed(q interface{}) error {
func (m *Migrate) ExportDataDump(tableNames []string) ([]byte, error) {
// to support tables starting with capital letters
modifiedTableNames := make([]string, len(tableNames))
for idx, val := range tableNames {
modifiedTableNames[idx] = fmt.Sprintf(`"%s"`, val)
split := strings.Split(val, ".")
splitLen := len(split)
if splitLen != 1 && splitLen != 2 {
return nil, fmt.Errorf(`invalid schema/table provided "%s"`, val)
}
if splitLen == 2 {
modifiedTableNames[idx] = fmt.Sprintf(`"%s"."%s"`, split[0], split[1])
} else {
modifiedTableNames[idx] = fmt.Sprintf(`"%s"`, val)
}
}
return m.databaseDrv.ExportDataDump(modifiedTableNames)
}