Skip to content

Commit 893bcec

Browse files
committed
add admin
1 parent 6b7bfcd commit 893bcec

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

packages/pgsql-test/src/admin.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,13 @@ export class DbAdmin {
115115
await this.streamSql(sql, db);
116116
}
117117

118+
// TODO: make adminRole a configurable option
119+
// ONLY granting admin role for testing purposes, normally the db connection for apps won't have admin role
120+
// DO NOT USE THIS FOR PRODUCTION
118121
async createUserRole(user: string, password: string, dbName: string): Promise<void> {
119122
const anonRole = getRoleName('anonymous', this.roleConfig);
120123
const authRole = getRoleName('authenticated', this.roleConfig);
124+
const adminRole = getRoleName('administrator', this.roleConfig);
121125

122126
const sql = `
123127
DO $$
@@ -126,6 +130,7 @@ export class DbAdmin {
126130
CREATE ROLE ${user} LOGIN PASSWORD '${password}';
127131
GRANT ${anonRole} TO ${user};
128132
GRANT ${authRole} TO ${user};
133+
GRANT ${adminRole} TO ${user};
129134
END IF;
130135
END $$;
131136
`.trim();

0 commit comments

Comments
 (0)