这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ If you do have such headers configured, then you must update the header configur
- console: update sidebar icons for different action and trigger types (#5445)
- console: make add column UX consistent with others (#5486)
- cli: improve error messages thrown when metadata apply fails (#5513)
- cli: fix issue with creating seed migrations while using tables with capital letters (closes #5532) (#5549)
- build: introduce additional log kinds for cli-migrations image (#5529)

## `v1.3.0`
Expand Down
10 changes: 5 additions & 5 deletions cli/commands/seed_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,26 +70,26 @@ func (o *SeedNewOptions) Run() error {
// If we are initializing from a database table
// create a hasura client and add table name opts
if createSeedOpts.Data == nil {
var body []byte
if len(o.FromTableNames) > 0 {
migrateDriver, err := migrate.NewMigrate(ec, true)
if err != nil {
return errors.Wrap(err, "cannot initialize migrate driver")
}
// Send the query
body, err := migrateDriver.ExportDataDump(o.FromTableNames)
body, err = migrateDriver.ExportDataDump(o.FromTableNames)
if err != nil {
return errors.Wrap(err, "exporting seed data")
}

createSeedOpts.Data = bytes.NewReader(body)
} else {
const defaultText = ""
data, err := editor.CaptureInputFromEditor(editor.GetPreferredEditorFromEnvironment, defaultText, "*.sql")
var err error
body, err = editor.CaptureInputFromEditor(editor.GetPreferredEditorFromEnvironment, defaultText, "*.sql")
if err != nil {
return errors.Wrap(err, "cannot find default editor from env")
}
createSeedOpts.Data = bytes.NewReader(data)
}
createSeedOpts.Data = bytes.NewReader(body)
}

fs := afero.NewOsFs()
Expand Down
7 changes: 6 additions & 1 deletion cli/migrate/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -1847,7 +1847,12 @@ func (m *Migrate) ApplySeed(q interface{}) error {
}

func (m *Migrate) ExportDataDump(tableNames []string) ([]byte, error) {
return m.databaseDrv.ExportDataDump(tableNames)
// to support tables starting with capital letters
modifiedTableNames := make([]string, len(tableNames))
for idx, val := range tableNames {
modifiedTableNames[idx] = fmt.Sprintf(`"%s"`, val)
}
return m.databaseDrv.ExportDataDump(modifiedTableNames)
}

func printDryRunStatus(migrations []*Migration) *bytes.Buffer {
Expand Down