Matrix Docker Ansible eploy
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

20 行
955 B

  1. -- `CREATE USER` does not support `IF NOT EXISTS`, so we use this workaround to prevent an error and raise a notice instead.
  2. -- Seen here: https://stackoverflow.com/a/49858797
  3. DO $$
  4. BEGIN
  5. CREATE USER "{{ additional_db.username }}";
  6. EXCEPTION WHEN DUPLICATE_OBJECT THEN
  7. RAISE NOTICE 'not creating user "{{ additional_db.username }}", since it already exists';
  8. END
  9. $$;
  10. -- This is useful for initial user creation (since we don't assign a password above) and for handling subsequent password changes
  11. -- TODO - we should escape quotes in the password.
  12. ALTER ROLE "{{ additional_db.username }}" PASSWORD '{{ additional_db.password }}';
  13. -- This will generate an error on subsequent execution
  14. CREATE DATABASE "{{ additional_db.name }}" WITH LC_CTYPE 'C' LC_COLLATE 'C' OWNER "{{ additional_db.username }}";
  15. -- This is useful for changing the database owner subsequently
  16. ALTER DATABASE "{{ additional_db.name }}" OWNER TO "{{ additional_db.username }}";