Skip to content

Commit

Permalink
Use postgres as maintenance db unless maintaining postgres itself (#1339
Browse files Browse the repository at this point in the history
)

Fixes #1283.
  • Loading branch information
dfaust authored Jul 23, 2021
1 parent 34db44b commit f0d0dce
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sqlx-core/src/postgres/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ fn parse_for_maintenance(uri: &str) -> Result<(PgConnectOptions, String), Error>
.to_owned();

// switch us to the maintenance database
// use `postgres` _unless_ the current user is postgres, in which case, use `template1`
// use `postgres` _unless_ the database is postgres, in which case, use `template1`
// this matches the behavior of the `createdb` util
options.database = if options.username == "postgres" {
options.database = if database == "postgres" {
Some("template1".into())
} else {
Some("postgres".into())
Expand Down

0 comments on commit f0d0dce

Please sign in to comment.