## to be the ADMINUSER role, the role used to make database objects.
## TARGET_USER
## The user to be created or otherwise modified.
+## NEW_PASSWORD
+## The password to assign.
## NEW_DB
## The database to be created.
## NEW_DESCRIPTION
-## The description of the new object (database)
+## The description of the new object (database).
##
## Usage:
## The expectation is that first an administrative user will be created, then
SET DATESTYLE = 'ISO,MDY';
CREATE_ADMINUSER := CREATE ROLE $(TARGET_USER) LOGIN SUPERUSER CREATEROLE \
PASSWORD '$(NEW_PASSWORD)';
+SET_PASSWORD := ALTER ROLE $(TARGET_USER) PASSWORD '$(NEW_PASSWORD)'
## The available targets for make (make TARGET) are:
##
## Lesser used targets:
##
+## set-password Set the password of TARGET_USER to NEW_PASSWORD
+.PHONY: set-password
+set-password:
+ [ -n "$(NEW_PASSWORD)" ] \
+ || { printf 'The NEW_PASSWORD variable must be set\n' >&2 ; \
+ exit 1 ; }
+ ( $(PSQL_SETUP) \
+ printf "$(SET_PASSWORD)\n" ; \
+ ) \
+ | psql $(PSQL_ARGS) $(PSQL_SINGLE_TRANS) --set=ON_ERROR_STOP=y
+
+
## set-search_path Set the default search_path the database named
## by the TARGET_DB variable.
.PHONY: set-search_path