init: avoid errors when creating existing resources

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2024-08-29 15:55:41 +02:00
parent f7720f0d5a
commit fbc3376e79
No known key found for this signature in database
GPG Key ID: FE65CD384D5BF7B4
1 changed files with 7 additions and 1 deletions

View File

@ -3,7 +3,13 @@
-- Users
{% for user in (postgres_ha_users + postgres_ha_databases) %}
CREATE USER "{{ user.name | mandatory }}" PASSWORD '{{ user.pass | mandatory }}';
DO $$
BEGIN
CREATE USER "{{ user.name | mandatory }}" PASSWORD '{{ user.pass | mandatory }}';
EXCEPTION WHEN duplicate_object THEN
RAISE NOTICE '%, skipping', SQLERRM USING ERRCODE = SQLSTATE;
END
$$;
{% endfor %}
-- Databases