← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:fix-initial-remote-db-setup into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:fix-initial-remote-db-setup into launchpad:master.

Commit message:
Fix initial setup of remote databases

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/444166

`utilities/pgoptions.py` is only used by `database/schema/Makefile`, and almost all the places where its output is used override the database name.  The only place that doesn't is the code to check whether the `session_dev` database already exists before creating it.

The database options generated from the `launchpad-admin` config include `--dbname=launchpad_dev`, and when creating a new set of databases from scratch and checking whether `session_dev` exists, `launchpad_dev` doesn't exist yet - so as a result we got `psql: error: FATAL:  database "launchpad_dev" does not exist`, and `session_dev` never got created.

Simply dropping the `--dbname` option from the output fixes this.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:fix-initial-remote-db-setup into launchpad:master.
diff --git a/utilities/pgoptions.py b/utilities/pgoptions.py
index 05996b0..11337ca 100755
--- a/utilities/pgoptions.py
+++ b/utilities/pgoptions.py
@@ -35,6 +35,4 @@ if __name__ == "__main__":
     # connecting over TCP.
     if "host" in parsed_dsn and "user" in parsed_dsn:
         conn_opts.append("--username=%s" % parsed_dsn["user"])
-    if "dbname" in parsed_dsn:
-        conn_opts.append("--dbname=%s" % parsed_dsn["dbname"])
     print(" ".join(conn_opts))