@vrplatform/kysely 1.3.45-stage.37628933993 → 1.3.45-stage.37675719962
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,46 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import { sql } from 'kysely';
|
|
3
|
+
|
|
4
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
5
|
+
await sql`set local lock_timeout = '5s'`.execute(db);
|
|
6
|
+
// These lookup indexes scan existing multi-million-row tables.
|
|
7
|
+
await sql`set local statement_timeout = '10min'`.execute(db);
|
|
8
|
+
|
|
9
|
+
await sql`
|
|
10
|
+
create index if not exists reservation_journal_invalidation_covered_effect_idx
|
|
11
|
+
on accounting.reservation_journal_invalidation (covered_by_effect_id)
|
|
12
|
+
where covered_by_effect_id is not null
|
|
13
|
+
`.execute(db);
|
|
14
|
+
await sql`
|
|
15
|
+
create index if not exists reservation_journal_statement_impact_listing_idx
|
|
16
|
+
on accounting.reservation_journal_statement_impact (listing_id)
|
|
17
|
+
`.execute(db);
|
|
18
|
+
// The stale-only index cannot cover foreign-key checks for every tenant row.
|
|
19
|
+
await sql`
|
|
20
|
+
create index if not exists reservation_journal_state_tenant_idx
|
|
21
|
+
on accounting.reservation_journal_state (tenant_id)
|
|
22
|
+
`.execute(db);
|
|
23
|
+
await sql`
|
|
24
|
+
create index if not exists owner_statement_previous_idx
|
|
25
|
+
on public.owner_statement (previous_owner_statement_id)
|
|
26
|
+
where previous_owner_statement_id is not null
|
|
27
|
+
`.execute(db);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
31
|
+
await sql`set local lock_timeout = '5s'`.execute(db);
|
|
32
|
+
await sql`set local statement_timeout = '60s'`.execute(db);
|
|
33
|
+
|
|
34
|
+
await sql`
|
|
35
|
+
drop index if exists public.owner_statement_previous_idx
|
|
36
|
+
`.execute(db);
|
|
37
|
+
await sql`
|
|
38
|
+
drop index if exists accounting.reservation_journal_state_tenant_idx
|
|
39
|
+
`.execute(db);
|
|
40
|
+
await sql`
|
|
41
|
+
drop index if exists accounting.reservation_journal_statement_impact_listing_idx
|
|
42
|
+
`.execute(db);
|
|
43
|
+
await sql`
|
|
44
|
+
drop index if exists accounting.reservation_journal_invalidation_covered_effect_idx
|
|
45
|
+
`.execute(db);
|
|
46
|
+
}
|