Restore search_path after finishing migrations
This commit is contained in:
parent
42f58417e9
commit
fdc83faba0
@ -38,6 +38,9 @@ func Migrate(db *sql.DB, version int, o Options, asset AssetFunc) error {
|
||||
|
||||
var err error
|
||||
|
||||
searchPath := `public`
|
||||
_ = db.QueryRow(`SHOW search_path`).Scan(&searchPath)
|
||||
|
||||
if o.Schema != `` {
|
||||
_, _ = db.Exec(`CREATE SCHEMA IF NOT EXISTS ` + o.Schema)
|
||||
|
||||
@ -88,7 +91,7 @@ func Migrate(db *sql.DB, version int, o Options, asset AssetFunc) error {
|
||||
}
|
||||
|
||||
if o.Schema != `` {
|
||||
_, err = tx.Exec(`SET search_path TO ` + o.Schema + `,public`)
|
||||
_, err = tx.Exec(`SET search_path TO ` + searchPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user