@vrplatform/kysely 1.3.45-37986857510 → 1.3.45-38006595816
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,60 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import { sql } from 'kysely';
|
|
3
|
+
|
|
4
|
+
// Product events live in Control Plane public.events. The legacy regional sink
|
|
5
|
+
// received its last write on 2026-08-18 and was reconciled by PRO-16951.
|
|
6
|
+
// Hasura never delivered the tracking_event trigger rows, so they are dropped
|
|
7
|
+
// with the table and are not restored by down.
|
|
8
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
9
|
+
await sql`set local lock_timeout = '5s'`.execute(db);
|
|
10
|
+
await sql`set local statement_timeout = '240s'`.execute(db);
|
|
11
|
+
await sql`drop table if exists tracking.event`.execute(db);
|
|
12
|
+
await sql`
|
|
13
|
+
drop function if exists hdb_catalog."notify_hasura_tracking_event_INSERT"()
|
|
14
|
+
`.execute(db);
|
|
15
|
+
await sql`
|
|
16
|
+
drop function if exists hdb_catalog."notify_hasura_tracking_event_UPDATE"()
|
|
17
|
+
`.execute(db);
|
|
18
|
+
await sql`
|
|
19
|
+
delete from hdb_catalog.event_invocation_logs
|
|
20
|
+
where trigger_name = 'tracking_event'
|
|
21
|
+
`.execute(db);
|
|
22
|
+
await sql`
|
|
23
|
+
delete from hdb_catalog.event_log
|
|
24
|
+
where trigger_name = 'tracking_event'
|
|
25
|
+
and schema_name = 'tracking'
|
|
26
|
+
and table_name = 'event'
|
|
27
|
+
`.execute(db);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
31
|
+
await sql`
|
|
32
|
+
create table if not exists tracking.event (
|
|
33
|
+
id uuid default gen_random_uuid() not null primary key,
|
|
34
|
+
tenant_id uuid,
|
|
35
|
+
user_id uuid,
|
|
36
|
+
created_at timestamp with time zone default now() not null,
|
|
37
|
+
name text not null,
|
|
38
|
+
props jsonb not null,
|
|
39
|
+
package_name text not null,
|
|
40
|
+
tracked_at timestamp with time zone default now(),
|
|
41
|
+
"timestamp" timestamp without time zone
|
|
42
|
+
generated always as (coalesce(tracked_at, created_at)) stored
|
|
43
|
+
)
|
|
44
|
+
`.execute(db);
|
|
45
|
+
await sql`
|
|
46
|
+
create index if not exists event_name_created_at_idx
|
|
47
|
+
on tracking.event (name, created_at)
|
|
48
|
+
`.execute(db);
|
|
49
|
+
await sql`
|
|
50
|
+
create index if not exists event_name_tracked_at_idx
|
|
51
|
+
on tracking.event (name, tracked_at)
|
|
52
|
+
`.execute(db);
|
|
53
|
+
await sql`
|
|
54
|
+
create index if not exists event_tenant_id_name_idx
|
|
55
|
+
on tracking.event (tenant_id, name)
|
|
56
|
+
`.execute(db);
|
|
57
|
+
await sql`
|
|
58
|
+
create index if not exists event_user_id on tracking.event (user_id)
|
|
59
|
+
`.execute(db);
|
|
60
|
+
}
|