Skip to content

Commit

Permalink
chore: grant privileges to postgrest_api
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra committed Nov 16, 2023
1 parent 5976ee6 commit 76efaba
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions migrate/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ func grantPostgrestRolesToCurrentUser(pool *sql.DB, connection string) error {
return err
}
logger.Debugf("Granted postgrest_api to %s", user)

grantQuery := `
GRANT SELECT, UPDATE, DELETE, INSERT ON ALL TABLES IN SCHEMA public TO postgrest_api;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, UPDATE, DELETE, INSERT ON TABLES TO postgrest_api;
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO postgrest_api;
`
if _, err := pool.Exec(grantQuery); err != nil {
return err
}
logger.Debugf("Granted privileges to postgrest_api", user)

}

isPostgrestAnonGranted, err := checkIfRoleIsGranted(pool, "postgrest_anon", user)
Expand Down

0 comments on commit 76efaba

Please sign in to comment.