← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Colin Watson has proposed merging ~cjwatson/launchpad:fix-make-schema-in-charmed-deployment into launchpad:master.

Commit message:
Fix database initialization in charmed deployments

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

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.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:fix-make-schema-in-charmed-deployment into launchpad:master.
diff --git a/database/schema/Makefile b/database/schema/Makefile
index 317d19e..0b33795 100644
--- a/database/schema/Makefile
+++ b/database/schema/Makefile
@@ -123,11 +123,9 @@ create:
 	@ echo "* Vacuuming"
 	@ vacuumdb $(DBOPTS) -fz -d ${EMPTY_DBNAME}
 
-	@ echo "* Creating session database '${SESSION_DBNAME}' (if necessary)"
-	@if [ "$$((`psql $(DBOPTS) -l | grep -w ${SESSION_DBNAME} | wc -l`))" = '0' ]; \
-	    then ${CREATEDB} template0 ${SESSION_DBNAME} ; \
-	    psql $(DBOPTS) -q -d ${SESSION_DBNAME} -f launchpad_session.sql ; \
-	fi
+	@ echo "* Creating session database '${SESSION_DBNAME}'"
+	@ ${CREATEDB} template0 ${SESSION_DBNAME}
+	@ psql $(DBOPTS) -q -d ${SESSION_DBNAME} -f launchpad_session.sql
 	@ echo "* Creating session database '${TEST_SESSION_DBNAME}'"
 	@ ${CREATEDB} template0 ${TEST_SESSION_DBNAME}
 	@ psql $(DBOPTS) -q -d ${TEST_SESSION_DBNAME} -f launchpad_session.sql