Skip to content

Commit 6698aa9

Browse files
Merge pull request #70 from sebix/sql
fix: CREATE ROLE idempotency
2 parents 1002a3a + 0c0d3c9 commit 6698aa9

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

sql/notifications.sql

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,20 @@
99
BEGIN;
1010

1111

12-
CREATE ROLE IF NOT EXISTS eventdb_owner
13-
NOLOGIN NOSUPERUSER NOINHERIT NOCREATEDB CREATEROLE;
14-
CREATE ROLE IF NOT EXISTS eventdb_insert
15-
NOLOGIN NOSUPERUSER NOINHERIT NOCREATEDB CREATEROLE;
16-
CREATE ROLE IF NOT EXISTS eventdb_send_notifications
17-
NOLOGIN NOSUPERUSER NOINHERIT NOCREATEDB CREATEROLE;
12+
DO $$ BEGIN
13+
CREATE ROLE eventdb_owner NOLOGIN NOSUPERUSER NOINHERIT NOCREATEDB CREATEROLE;
14+
EXCEPTION WHEN duplicate_object THEN NULL;
15+
END $$;
16+
17+
DO $$ BEGIN
18+
CREATE ROLE eventdb_insert NOLOGIN NOSUPERUSER NOINHERIT NOCREATEDB CREATEROLE;
19+
EXCEPTION WHEN duplicate_object THEN NULL;
20+
END $$;
21+
22+
DO $$ BEGIN
23+
CREATE ROLE eventdb_send_notifications NOLOGIN NOSUPERUSER NOINHERIT NOCREATEDB CREATEROLE;
24+
EXCEPTION WHEN duplicate_object THEN NULL;
25+
END $$;
1826

1927
ALTER DATABASE :"DBNAME" OWNER TO eventdb_owner;
2028

0 commit comments

Comments
 (0)