On postgres put the schema in if it is set

Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
Andrew Thornton 2022-01-04 18:34:57 +00:00
parent 7dbf688ae9
commit b772658c0b
No known key found for this signature in database
GPG Key ID: 3CDE74631F13A748
1 changed files with 4 additions and 0 deletions

View File

@ -489,6 +489,10 @@ func (engine *Engine) dumpTables(ctx context.Context, tables []*schemas.Table, w
if _, err := io.WriteString(w, "SET sql_mode='NO_BACKSLASH_ESCAPES';\n"); err != nil { if _, err := io.WriteString(w, "SET sql_mode='NO_BACKSLASH_ESCAPES';\n"); err != nil {
return err return err
} }
} else if dstDialect.URI().DBType == schemas.POSTGRES && engine.dialect.URI().Schema != "" {
if _, err := fmt.Fprintf(w, `SELECT set_config('search_path', '%s,' || current_setting('search_path'), false)`, strings.ReplaceAll(engine.dialect.URI().Schema, "'", "''")); err != nil {
return err
}
} }
for i, table := range tables { for i, table := range tables {