From 3077ddf4a6d66b657f9bd369e64a0beec54d08b1 Mon Sep 17 00:00:00 2001 From: himeshr Date: Thu, 21 Nov 2024 19:44:35 +0530 Subject: [PATCH] avniproject/avni-etl#112 |Reference commands to fix openchs user on local db when it fails to perform create_db_user() action --- .../main/resources/database/usefulQueries.sql | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/avni-server-api/src/main/resources/database/usefulQueries.sql b/avni-server-api/src/main/resources/database/usefulQueries.sql index faa6d1eeb..43c3611d6 100644 --- a/avni-server-api/src/main/resources/database/usefulQueries.sql +++ b/avni-server-api/src/main/resources/database/usefulQueries.sql @@ -859,6 +859,21 @@ pg_dump --dbname=openchs --username=openchs --role= --file=/Users/test psql -U openchs --host=localhost --port=6015 -d openchs -f /Users/test/target-dump-update.sql -- to drop roles. check the oid value -select 'drop role "' || a.rolname || '";' FROM pg_roles a -WHERE pg_has_role('openchs', a.oid, 'member') AND a.rolname <> 'openchs' and a.oid > 1443729 +select 'drop role "' || a.rolname || '";' +FROM pg_roles a +WHERE pg_has_role('openchs', a.oid, 'member') + AND a.rolname <> 'openchs' + and a.oid > 1443729 order by a.oid; + + +-- START // To gain admin role option for openchs user, useful when newly creating openchs / avni_org DB +CREATE ROLE openchs; + +GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO openchs; + +GRANT ALL PRIVILEGES ON DATABASE "postgres" to openchs; + +ALTER USER openchs WITH SUPERUSER; + +-- END // To gain admin role option for openchs user, useful when newly creating openchs / avni_org DB