From: Bill Erickson Date: Thu, 13 Aug 2015 15:15:42 +0000 (-0400) Subject: JBAS-837 sqitch deploy avoids creating existing users X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=22fefa4c73cf6fb9dfe6da5cc3ef46c79d48a1e3;p=working%2FEvergreen.git JBAS-837 sqitch deploy avoids creating existing users When deploying to a PG instance that already has KCLS users, avoid trying to create them, which would result in a sqitch deployment failure. Signed-off-by: Bill Erickson --- diff --git a/KCLS/sqitch/deploy/kcls-2.4-base-prod.sql b/KCLS/sqitch/deploy/kcls-2.4-base-prod.sql index a85377a9c0..61cfb81385 100644 --- a/KCLS/sqitch/deploy/kcls-2.4-base-prod.sql +++ b/KCLS/sqitch/deploy/kcls-2.4-base-prod.sql @@ -1,19 +1,27 @@ - - -- Generated 2015-04-21 10:41:11 on db03.eg.kcls.org --- These custom users may already exist... errors are OK. - BEGIN; -CREATE USER bbonner; -CREATE USER biblio; -CREATE USER kclsreporter; -CREATE USER kclsreporter2; - - \set ON_ERROR_STOP on +DO +$BODY$ +BEGIN + -- When deploying to an existing postgres instance, + -- these users may already exist. + IF NOT EXISTS ( + SELECT * + FROM pg_catalog.pg_user + WHERE usename = 'bbonner') THEN + -- if bbonner is not present, assume the other's aren't. + CREATE USER bbonner; + CREATE USER biblio; + CREATE USER kclsreporter; + CREATE USER kclsreporter2; + END IF; +END +$BODY$; + -- -- PostgreSQL database dump