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

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: e989e53a6a618c281d863a57db2f104f6d54a1e4
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:fix-initial-remote-db-setup
Merge into: launchpad:master
Diff against target: 11 lines (+0/-2)
1 file modified
utilities/pgoptions.py (+0/-2)
Reviewer Review Type Date Requested Status
Ines Almeida Approve
Review via email: mp+444166@code.launchpad.net

Commit message

Fix initial setup of remote databases

Description of the change

`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.

To post a comment you must log in.
Revision history for this message
Ines Almeida (ines-almeida) wrote :

LGTM!
Don't we need to remove `dbname` from wherever `parsed_dsn` gets setup? (I didn't look through the code, might not be used at all!)

review: Approve
Revision history for this message
Colin Watson (cjwatson) wrote :

No need - `parsed_dsn` is only used here to build `conn_opts`, and the bits of it that aren't used for that are simply ignored.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/utilities/pgoptions.py b/utilities/pgoptions.py
2index 05996b0..11337ca 100755
3--- a/utilities/pgoptions.py
4+++ b/utilities/pgoptions.py
5@@ -35,6 +35,4 @@ if __name__ == "__main__":
6 # connecting over TCP.
7 if "host" in parsed_dsn and "user" in parsed_dsn:
8 conn_opts.append("--username=%s" % parsed_dsn["user"])
9- if "dbname" in parsed_dsn:
10- conn_opts.append("--dbname=%s" % parsed_dsn["dbname"])
11 print(" ".join(conn_opts))

Subscribers

People subscribed via source and target branches

to status/vote changes: