Skip to content

Commit

Permalink
fix(role-grafana): correct variable usage
Browse files Browse the repository at this point in the history
  • Loading branch information
dargmuesli committed Dec 1, 2023
1 parent 0c6bc6e commit 5cedd46
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/deploy/role_grafana.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ BEGIN;
\set role_grafana_username `cat /run/secrets/postgres_role_grafana_username`

CREATE ROLE :role_grafana_username LOGIN PASSWORD :'role_grafana_password';
;

GRANT ALL PRIVILEGES ON DATABASE grafana TO :role_grafana_username;
GRANT ALL ON SCHEMA public TO :role_grafana_username;

Expand Down
2 changes: 1 addition & 1 deletion src/revert/database_grafana.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-- Revert maevsi:database_grafana from pg

DROP DATABASE grafana;
DROP DATABASE grafana WITH (FORCE);
6 changes: 4 additions & 2 deletions src/revert/role_grafana.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

BEGIN;

DROP OWNED BY grafana;
DROP ROLE grafana;
\set role_grafana_username `cat /run/secrets/postgres_role_grafana_username`

DROP OWNED BY :role_grafana_username;
DROP ROLE :role_grafana_username;

COMMIT;
6 changes: 5 additions & 1 deletion src/verify/role_grafana.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@

BEGIN;

\set role_grafana_username `cat /run/secrets/postgres_role_grafana_username`

SET LOCAL sqitch.role_grafana_username TO :'role_grafana_username';

DO $$
BEGIN
ASSERT (SELECT pg_catalog.pg_has_role('grafana', 'USAGE'));
ASSERT (SELECT pg_catalog.pg_has_role(current_setting('sqitch.role_grafana_username'), 'USAGE'));
-- Other accounts might not exist yet for a NOT-check.
END $$;

Expand Down

0 comments on commit 5cedd46

Please sign in to comment.