Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/db/src/provision.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ describe("provisionStatements", () => {
`CREATE ROLE "monmap" LOGIN NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION CONNECTION LIMIT 20 PASSWORD 'pw'`,
`GRANT "monmap" TO CURRENT_USER`,
`CREATE DATABASE "monmap" OWNER "monmap"`,
`REVOKE "monmap" FROM CURRENT_USER`,
`REVOKE ALL ON DATABASE "monmap" FROM PUBLIC`,
`GRANT CONNECT, TEMPORARY ON DATABASE "monmap" TO "monmap"`,
`REVOKE "monmap" FROM CURRENT_USER`,
]);
});

Expand Down
8 changes: 5 additions & 3 deletions packages/db/src/provision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ export function provisionStatements(options: ProvisionOptions): string[] {

return [
`CREATE ROLE "${app}" LOGIN NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION CONNECTION LIMIT ${limit} PASSWORD ${quoteLiteral(password)}`,
// A managed server's administrator is not a superuser, and may only hand
// a database to a role it is a member of. It joins for that one statement.
// A managed server's administrator is not a superuser. It may only hand
// a database to a role it is a member of, and only change the privileges
// of a database it owns through that role, so it joins the role until the
// database is locked down and leaves last.
`GRANT "${app}" TO CURRENT_USER`,
`CREATE DATABASE "${app}" OWNER "${app}"`,
`REVOKE "${app}" FROM CURRENT_USER`,
`REVOKE ALL ON DATABASE "${app}" FROM PUBLIC`,
`GRANT CONNECT, TEMPORARY ON DATABASE "${app}" TO "${app}"`,
`REVOKE "${app}" FROM CURRENT_USER`,
];
}

Expand Down
Loading