Merge pull request #845 from o8F0LY/improve-matrix-postgres-init-additional-db-user-and-role

Add double quotes 'matrix-postgres-init-additional-db-user-and-role.sql.j2' template
development
Slavi Pantaleev 4 years ago committed by GitHub
commit c97dd5dc2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,18 +2,18 @@
-- Seen here: https://stackoverflow.com/a/49858797 -- Seen here: https://stackoverflow.com/a/49858797
DO $$ DO $$
BEGIN BEGIN
CREATE USER {{ additional_db.username }}; CREATE USER "{{ additional_db.username }}";
EXCEPTION WHEN DUPLICATE_OBJECT THEN EXCEPTION WHEN DUPLICATE_OBJECT THEN
RAISE NOTICE 'not creating user {{ additional_db.username }}, since it already exists'; RAISE NOTICE 'not creating user "{{ additional_db.username }}", since it already exists';
END END
$$; $$;
-- This is useful for initial user creation (since we don't assign a password above) and for handling subsequent password changes -- This is useful for initial user creation (since we don't assign a password above) and for handling subsequent password changes
-- TODO - we should escape quotes in the password. -- TODO - we should escape quotes in the password.
ALTER ROLE {{ additional_db.username }} PASSWORD '{{ additional_db.password }}'; ALTER ROLE "{{ additional_db.username }}" PASSWORD '{{ additional_db.password }}';
-- This will generate an error on subsequent execution -- This will generate an error on subsequent execution
CREATE DATABASE {{ additional_db.name }} WITH LC_CTYPE 'C' LC_COLLATE 'C' OWNER {{ additional_db.username }}; CREATE DATABASE "{{ additional_db.name }}" WITH LC_CTYPE 'C' LC_COLLATE 'C' OWNER "{{ additional_db.username }}";
-- This is useful for changing the database owner subsequently -- This is useful for changing the database owner subsequently
ALTER DATABASE {{ additional_db.name }} OWNER TO {{ additional_db.username }}; ALTER DATABASE "{{ additional_db.name }}" OWNER TO "{{ additional_db.username }}";

Loading…
Cancel
Save