@vrplatform/kysely 1.3.45-stage.4399 → 1.3.45-stage.4401
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import { sql } from 'kysely';
|
|
3
|
+
|
|
4
|
+
export async function up(db: Kysely<any>): Promise<void> {
|
|
5
|
+
await sql`
|
|
6
|
+
do $$
|
|
7
|
+
begin
|
|
8
|
+
if exists (select 1 from pg_roles where rolname = 'application') then
|
|
9
|
+
grant usage on schema health, webhook to application;
|
|
10
|
+
grant select, insert, update, delete
|
|
11
|
+
on all tables in schema health, webhook to application;
|
|
12
|
+
grant usage, select, update
|
|
13
|
+
on all sequences in schema health, webhook to application;
|
|
14
|
+
alter default privileges in schema health, webhook
|
|
15
|
+
grant select, insert, update, delete on tables to application;
|
|
16
|
+
alter default privileges in schema health, webhook
|
|
17
|
+
grant usage, select, update on sequences to application;
|
|
18
|
+
end if;
|
|
19
|
+
end
|
|
20
|
+
$$;
|
|
21
|
+
`.execute(db);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function down(db: Kysely<any>): Promise<void> {
|
|
25
|
+
await sql`
|
|
26
|
+
do $$
|
|
27
|
+
begin
|
|
28
|
+
if exists (select 1 from pg_roles where rolname = 'application') then
|
|
29
|
+
alter default privileges in schema health, webhook
|
|
30
|
+
revoke select, insert, update, delete on tables from application;
|
|
31
|
+
alter default privileges in schema health, webhook
|
|
32
|
+
revoke usage, select, update on sequences from application;
|
|
33
|
+
revoke select, insert, update, delete
|
|
34
|
+
on all tables in schema health, webhook from application;
|
|
35
|
+
revoke usage, select, update
|
|
36
|
+
on all sequences in schema health, webhook from application;
|
|
37
|
+
revoke usage on schema health, webhook from application;
|
|
38
|
+
end if;
|
|
39
|
+
end
|
|
40
|
+
$$;
|
|
41
|
+
`.execute(db);
|
|
42
|
+
}
|