Skip to content

Commit 4fba877

Browse files
committed
administrator cleanup
1 parent df67860 commit 4fba877

File tree

6 files changed

+63
-19
lines changed

6 files changed

+63
-19
lines changed

packages/ast/deploy/schemas/ast_utils/procedures/utils.sql

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,13 @@ BEGIN
125125
ELSIF (targtype = 'ACL_TARGET_DEFAULTS') THEN
126126
RETURN 'TABLES';
127127
END IF;
128-
-- TODO could be a view
129128
RETURN 'TABLE';
130129
ELSIF (objtype = 'OBJECT_SEQUENCE') THEN
130+
IF (targtype = 'ACL_TARGET_ALL_IN_SCHEMA') THEN
131+
RETURN 'ALL SEQUENCES IN SCHEMA';
132+
ELSIF (targtype = 'ACL_TARGET_DEFAULTS') THEN
133+
RETURN 'SEQUENCES';
134+
END IF;
131135
RETURN 'SEQUENCE';
132136
ELSIF (objtype = 'OBJECT_DATABASE') THEN
133137
RETURN 'DATABASE';

packages/ast/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
"graphql": "^14.0.2",
3030
"graphql-tag": "2.10.3",
3131
"jest": "26.1.0",
32-
"pgsql-parser": "13.1.0",
33-
"pgsql-deparser": "13.1.0",
32+
"pgsql-parser": "13.1.1",
33+
"pgsql-deparser": "13.1.1",
3434
"prettier": "2.0.5",
3535
"regenerator-runtime": "^0.13.2"
3636
},
@@ -42,4 +42,4 @@
4242
"__fixtures__"
4343
]
4444
}
45-
}
45+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name GRANT SELECT ON TABLES TO your_user;
2+
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name GRANT ALL ON TABLES TO your_user;
3+
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name GRANT ALL ON SEQUENCES TO your_user;
4+
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name GRANT ALL ON FUNCTIONS TO your_user;
5+
6+
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA schema_name TO your_user;
7+
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA schema_name TO your_user;
8+
GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA schema_name TO your_user;

packages/ast/test/__tests__/__snapshots__/kitchen-sink.test.js.snap

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7895,3 +7895,31 @@ b bpchar
78957895
CREATE FUNCTION charfunc ( a pg_catalog.\\"char\\", b \\"char\\", c char(1) ) RETURNS void AS $EOFCODE$BEGIN
78967896
END;$EOFCODE$ LANGUAGE plpgsql VOLATILE;"
78977897
`;
7898+
7899+
exports[`privs-and-defaults 1`] = `
7900+
"ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name
7901+
GRANT SELECT ON TABLES TO your_user;
7902+
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name
7903+
GRANT ALL ON TABLES TO your_user;
7904+
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name
7905+
GRANT ALL ON SEQUENCES TO your_user;
7906+
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name
7907+
GRANT ALL ON FUNCTIONS TO your_user;
7908+
GRANT ALL ON ALL TABLES IN SCHEMA schema_name TO your_user;
7909+
GRANT ALL ON ALL SEQUENCES IN SCHEMA schema_name TO your_user;
7910+
GRANT ALL ON ALL FUNCTIONS IN SCHEMA schema_name TO your_user;"
7911+
`;
7912+
7913+
exports[`privs-and-defaults 2`] = `
7914+
"ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name
7915+
GRANT SELECT ON TABLES TO your_user;
7916+
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name
7917+
GRANT ALL ON TABLES TO your_user;
7918+
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name
7919+
GRANT ALL ON SEQUENCES TO your_user;
7920+
ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name
7921+
GRANT ALL ON FUNCTIONS TO your_user;
7922+
GRANT ALL ON ALL TABLES IN SCHEMA schema_name TO your_user;
7923+
GRANT ALL ON ALL SEQUENCES IN SCHEMA schema_name TO your_user;
7924+
GRANT ALL ON ALL FUNCTIONS IN SCHEMA schema_name TO your_user;"
7925+
`;

packages/ast/test/__tests__/kitchen-sink.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ export const check = async (file) => {
5252
expect(cleanTree(parser.parse(sqlfromparser))).toEqual(originalTree);
5353
};
5454

55+
it('privs-and-defaults', async () => {
56+
await check('privs-and-defaults.sql');
57+
});
58+
5559
it('parens', async () => {
5660
await check('parens.sql');
5761
});

yarn.lock

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8434,25 +8434,25 @@ [email protected]:
84348434
dependencies:
84358435
split "^1.0.0"
84368436

8437-
pgsql-deparser@^1.2.2:
8438-
version "1.2.3"
8439-
resolved "https://registry.npmjs.org/pgsql-deparser/-/pgsql-deparser-1.2.3.tgz#b426f7cc25e273690ff030701e833fcfed10ef50"
8440-
integrity sha512-0EBrmPqevIkS+zlV4eqa8Pjds5LXFXGKzRJUG8Ca0kI097fxOBcJWiY4qIwWNjmJMpixqu2K6aBW6Di6rxFhiQ==
8437+
pgsql-deparser@13.1.1, pgsql-deparser@^13.1.1:
8438+
version "13.1.1"
8439+
resolved "https://registry.npmjs.org/pgsql-deparser/-/pgsql-deparser-13.1.1.tgz#95a3a9c1b73ffca6095fa2e7839447d23d67f972"
8440+
integrity sha512-V8fKumXROotviMqQ1HVRJUqjVd6P5lKaigZJYnK3bo6cjCbJMpmiHNaIFIlordXLbS/3VE5MAQKMFfPVLuhH+w==
84418441
dependencies:
84428442
"@babel/runtime" "^7.11.2"
84438443
dotty "0.1.0"
84448444
lodash "4.17.20"
8445-
pgsql-enums "^1.0.2"
8445+
pgsql-enums "^13.1.0"
84468446

8447-
pgsql-deparser@^13.1.0:
8448-
version "13.1.0"
8449-
resolved "https://registry.npmjs.org/pgsql-deparser/-/pgsql-deparser-13.1.0.tgz#c1864439f16533fa5973b94a62f55c62c8e2d522"
8450-
integrity sha512-dFOJmOQQY/6UBP21IlHhJpKR4lQFLrNY2BxINf7pHbqBYlTyCSVMf2iTuXVrGs30xMqIHAdoGokRMPqg+shAlQ==
8447+
pgsql-deparser@^1.2.2:
8448+
version "1.2.3"
8449+
resolved "https://registry.npmjs.org/pgsql-deparser/-/pgsql-deparser-1.2.3.tgz#b426f7cc25e273690ff030701e833fcfed10ef50"
8450+
integrity sha512-0EBrmPqevIkS+zlV4eqa8Pjds5LXFXGKzRJUG8Ca0kI097fxOBcJWiY4qIwWNjmJMpixqu2K6aBW6Di6rxFhiQ==
84518451
dependencies:
84528452
"@babel/runtime" "^7.11.2"
84538453
dotty "0.1.0"
84548454
lodash "4.17.20"
8455-
pgsql-enums "^13.1.0"
8455+
pgsql-enums "^1.0.2"
84568456

84578457
pgsql-enums@^1.0.2:
84588458
version "1.0.2"
@@ -8490,15 +8490,15 @@ [email protected]:
84908490
pgsql-deparser "^1.2.2"
84918491
pgsql-enums "^1.0.2"
84928492

8493-
8494-
version "13.1.0"
8495-
resolved "https://registry.npmjs.org/pgsql-parser/-/pgsql-parser-13.1.0.tgz#d21817e6f1ae22c28a8b5e31d4cacc4c3444e903"
8496-
integrity sha512-omkO76fk+TNBGuU1X7C30/g4Di0t5C7sw7QIRri1oxmL0BKk39sDilwpM0X6QGUfxYz7jcZ7wOY+qmYvLOMoaQ==
8493+
8494+
version "13.1.1"
8495+
resolved "https://registry.npmjs.org/pgsql-parser/-/pgsql-parser-13.1.1.tgz#7153d9fc114d7d66ae75258c464be18dc2bf24f0"
8496+
integrity sha512-Fh7Svor+9lAue9/vICvx+PlJB9W7SKfVuhfY1S72NX2gk5onrbMZXeY2vhd4AYzTzk9JumA+alNmb5/htCX9gg==
84978497
dependencies:
84988498
"@babel/runtime" "^7.11.2"
84998499
libpg-query "13.0.1"
85008500
minimist "^1.2.5"
8501-
pgsql-deparser "^13.1.0"
8501+
pgsql-deparser "^13.1.1"
85028502
pgsql-enums "^13.1.0"
85038503

85048504
picomatch@^2.0.4, picomatch@^2.0.5:

0 commit comments

Comments
 (0)