Skip to content

Commit c671053

Browse files
committed
adding macrostrat user permissions to all schemas and tables in macrostrat database
1 parent 375049b commit c671053

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

cli/macrostrat/cli/database/migrations/baseline/01-roles.sql

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,45 @@ GRANT SELECT ON ALL TABLES IN SCHEMA macrostrat TO "rockd-reader";
2727
GRANT SELECT ON ALL TABLES IN SCHEMA public TO "rockd-reader";
2828
GRANT SELECT ON ALL TABLES IN SCHEMA topology TO "rockd-reader";
2929

30+
-- 1) Schema access
31+
GRANT USAGE ON SCHEMA
32+
carto, carto_new, geologic_boundaries, hexgrids, lines,
33+
macrostrat, maps, points, sources, topology, public
34+
TO macrostrat;
35+
36+
-- 2) Read all existing objects (tables/views + sequences)
37+
GRANT SELECT ON ALL TABLES IN SCHEMA
38+
carto, carto_new, geologic_boundaries, hexgrids, lines,
39+
macrostrat, maps, points, sources, topology, public
40+
TO macrostrat;
41+
42+
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA
43+
carto, carto_new, geologic_boundaries, hexgrids, lines,
44+
macrostrat, maps, points, sources, topology, public
45+
TO macrostrat;
46+
47+
-- 3) Make future objects readable by default (run as each object-creating owner)
48+
ALTER DEFAULT PRIVILEGES IN SCHEMA
49+
carto, carto_new, geologic_boundaries, hexgrids, lines,
50+
macrostrat, maps, points, sources, topology, public
51+
GRANT SELECT ON TABLES TO macrostrat;
52+
53+
ALTER DEFAULT PRIVILEGES IN SCHEMA
54+
carto, carto_new, geologic_boundaries, hexgrids, lines,
55+
macrostrat, maps, points, sources, topology, public
56+
GRANT USAGE, SELECT ON SEQUENCES TO macrostrat;
57+
58+
-- 4) Enums used in tables under public
59+
GRANT USAGE ON TYPE
60+
public.measurement_class,
61+
public.measurement_class_new,
62+
public.measurement_type,
63+
public.measurement_type_new
64+
TO macrostrat;
65+
66+
-- 5) Functions (your helper + PostGIS etc.) – safe & useful for read paths
67+
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public, topology TO macrostrat;
68+
3069

3170
--POSTGREST helper functions for RLS security
3271
--Pull `"user_id"` out of the JWT that PostgREST stores in request.jwt.claims

0 commit comments

Comments
 (0)