@vrplatform/kysely 1.3.45-1174 → 1.3.45-1176
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
|
+
// Hasura's tracking_connection trigger copies the whole connection row,
|
|
5
|
+
// including credentials, into hdb_catalog.event_log. Hasura regenerates its own
|
|
6
|
+
// trigger functions from metadata, so the credentials are stripped on the
|
|
7
|
+
// event_log insert instead. The webhook consumer reads id, tenant_id, app_id and
|
|
8
|
+
// status only.
|
|
9
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
10
|
+
await sql`set local lock_timeout = '5s'`.execute(db);
|
|
11
|
+
|
|
12
|
+
await sql`
|
|
13
|
+
create or replace function public.strip_connection_event_credentials()
|
|
14
|
+
returns trigger
|
|
15
|
+
language plpgsql
|
|
16
|
+
as $$
|
|
17
|
+
begin
|
|
18
|
+
new.payload := new.payload #- '{data,old,credentials}' #- '{data,new,credentials}';
|
|
19
|
+
return new;
|
|
20
|
+
end;
|
|
21
|
+
$$
|
|
22
|
+
`.execute(db);
|
|
23
|
+
await sql`
|
|
24
|
+
drop trigger if exists strip_connection_credentials on hdb_catalog.event_log
|
|
25
|
+
`.execute(db);
|
|
26
|
+
await sql`
|
|
27
|
+
create trigger strip_connection_credentials
|
|
28
|
+
before insert on hdb_catalog.event_log
|
|
29
|
+
for each row
|
|
30
|
+
when (new.schema_name = 'public' and new.table_name = 'connection')
|
|
31
|
+
execute function public.strip_connection_event_credentials()
|
|
32
|
+
`.execute(db);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
36
|
+
await sql`
|
|
37
|
+
drop trigger if exists strip_connection_credentials on hdb_catalog.event_log
|
|
38
|
+
`.execute(db);
|
|
39
|
+
await sql`
|
|
40
|
+
drop function if exists public.strip_connection_event_credentials()
|
|
41
|
+
`.execute(db);
|
|
42
|
+
}
|