Merge ~cjwatson/launchpad:fix-make-schema-in-charmed-deployment into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 4b5fe2a49cbd998ae456de42a66fba6422df5362
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:fix-make-schema-in-charmed-deployment
Merge into: launchpad:master
Diff against target: 19 lines (+3/-5)
1 file modified
database/schema/Makefile (+3/-5)
Reviewer Review Type Date Requested Status
Ines Almeida Approve
Review via email: mp+444933@code.launchpad.net

Commit message

Fix database initialization in charmed deployments

Description of the change

In charmed deployments, `launchpad-admin` is typically related to `postgresql`, which causes the `postgresql` charm to automatically create an empty `session_dev` database. This confuses the `create` target in `database/schema/Makefile` into assuming that the `session_dev` database has already been initialized and not doing so again.

I couldn't find any record in git history of why we bother to perform this check for `session_dev` when we don't do so for any of the other databases. I think it makes more sense to assume that if you're running the `create` target then you mean to actually create all the databases, so this commit brings the handling of `session_dev` into line with all the other databases.

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

LGTM!
Happy to see this issue going away! :D

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/database/schema/Makefile b/database/schema/Makefile
2index 317d19e..0b33795 100644
3--- a/database/schema/Makefile
4+++ b/database/schema/Makefile
5@@ -123,11 +123,9 @@ create:
6 @ echo "* Vacuuming"
7 @ vacuumdb $(DBOPTS) -fz -d ${EMPTY_DBNAME}
8
9- @ echo "* Creating session database '${SESSION_DBNAME}' (if necessary)"
10- @if [ "$$((`psql $(DBOPTS) -l | grep -w ${SESSION_DBNAME} | wc -l`))" = '0' ]; \
11- then ${CREATEDB} template0 ${SESSION_DBNAME} ; \
12- psql $(DBOPTS) -q -d ${SESSION_DBNAME} -f launchpad_session.sql ; \
13- fi
14+ @ echo "* Creating session database '${SESSION_DBNAME}'"
15+ @ ${CREATEDB} template0 ${SESSION_DBNAME}
16+ @ psql $(DBOPTS) -q -d ${SESSION_DBNAME} -f launchpad_session.sql
17 @ echo "* Creating session database '${TEST_SESSION_DBNAME}'"
18 @ ${CREATEDB} template0 ${TEST_SESSION_DBNAME}
19 @ psql $(DBOPTS) -q -d ${TEST_SESSION_DBNAME} -f launchpad_session.sql

Subscribers

People subscribed via source and target branches

to status/vote changes: