Skip to content

Commit

Permalink
Add Schema Qualifier to SQL statements
Browse files Browse the repository at this point in the history
- Write to Permissions schema instead of Metadata
  • Loading branch information
Mythicaeda committed Mar 21, 2024
1 parent 4f9de05 commit ce36b01
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/packages/auth/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export async function getUserRoles(
const { rows, rowCount } = await db.query(
`
select hasura_default_role, hasura_allowed_roles
from metadata.users_and_roles
from permissions.users_and_roles
where username = $1;
`,
[username],
Expand All @@ -66,7 +66,7 @@ export async function deleteUserAllowedRoles(username: string) {

await db.query(
`
delete from metadata.users_allowed_roles
delete from permissions.users_allowed_roles
where username = $1;
`,
[username],
Expand All @@ -78,7 +78,7 @@ export async function upsertUserRoles(username: string, default_role: string, al

await db.query(
`
insert into metadata.users (username, default_role)
insert into permissions.users (username, default_role)
values ($1, $2)
on conflict (username) do update
set default_role = excluded.default_role;
Expand All @@ -89,7 +89,7 @@ export async function upsertUserRoles(username: string, default_role: string, al
for (const allowed_role of allowed_roles) {
await db.query(
`
insert into metadata.users_allowed_roles (username, allowed_role)
insert into permissions.users_allowed_roles (username, allowed_role)
values ($1, $2)
`,
[username, allowed_role],
Expand Down
4 changes: 2 additions & 2 deletions src/packages/files/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default (app: Express) => {
const deleted_date = new Date();
const { rowCount } = await db.query(
`
update uploaded_file
update merlin.uploaded_file
set deleted_date = $1
where id = $2;
`,
Expand Down Expand Up @@ -123,7 +123,7 @@ export default (app: Express) => {
// twice so the query casts it appropriately to each type.
const { rowCount, rows } = await db.query(
`
insert into uploaded_file (name, path)
insert into merlin.uploaded_file (name, path)
values ($1, $2)
returning id;
`,
Expand Down

0 comments on commit ce36b01

Please sign in to comment.