@vrplatform/kysely 1.3.41-stage.4207 → 1.3.41-stage.4216
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.
- package/build/migrations/0000000000041-audit-tenant-fk.ts +66 -0
- package/package.json +1 -1
- /package/build/migrations/{0000000000038-ramp-staging-connect-params.ts → 0000000000042-ramp-staging-connect-params.ts} +0 -0
- /package/build/migrations/{0000000000039-gl-pms-accounting-window-guard.ts → 0000000000043-gl-pms-accounting-window-guard.ts} +0 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import { sql } from 'kysely';
|
|
3
|
+
|
|
4
|
+
// The audit schema is an append-only trail that outlives placement: actions
|
|
5
|
+
// can be performed by tenants homed in other regions (cell workers), and the
|
|
6
|
+
// audit rows of a delete action are written after the tenant row is gone.
|
|
7
|
+
// Tenant deletion already purges audit rows explicitly
|
|
8
|
+
// (packages/repository/src/tenant/delete.ts), so the tenant FKs (and their
|
|
9
|
+
// redundant cascades) only cause false failures; drop them.
|
|
10
|
+
export async function up(db: Kysely<any>): Promise<void> {
|
|
11
|
+
await sql`
|
|
12
|
+
alter table audit.action
|
|
13
|
+
drop constraint if exists action_tenant_id_fkey;
|
|
14
|
+
`.execute(db);
|
|
15
|
+
await sql`
|
|
16
|
+
alter table audit.mutation
|
|
17
|
+
drop constraint if exists mutation_tenant_id_fkey;
|
|
18
|
+
`.execute(db);
|
|
19
|
+
await sql`
|
|
20
|
+
alter table audit.effect
|
|
21
|
+
drop constraint if exists effect_tenant_id_fkey;
|
|
22
|
+
`.execute(db);
|
|
23
|
+
await sql`
|
|
24
|
+
alter table audit.effect_attempt
|
|
25
|
+
drop constraint if exists effect_attempt_tenant_id_fkey;
|
|
26
|
+
`.execute(db);
|
|
27
|
+
await sql`
|
|
28
|
+
alter table audit.journal_delta
|
|
29
|
+
drop constraint if exists journal_delta_tenant_id_fkey;
|
|
30
|
+
`.execute(db);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function down(db: Kysely<any>): Promise<void> {
|
|
34
|
+
// NOT VALID: rows referencing since-deleted or cross-region tenants may
|
|
35
|
+
// legitimately exist; only future writes are constrained again.
|
|
36
|
+
await sql`
|
|
37
|
+
alter table audit.action
|
|
38
|
+
add constraint action_tenant_id_fkey
|
|
39
|
+
foreign key (tenant_id) references public.tenant(id)
|
|
40
|
+
on delete cascade not valid;
|
|
41
|
+
`.execute(db);
|
|
42
|
+
await sql`
|
|
43
|
+
alter table audit.mutation
|
|
44
|
+
add constraint mutation_tenant_id_fkey
|
|
45
|
+
foreign key (tenant_id) references public.tenant(id)
|
|
46
|
+
on delete cascade not valid;
|
|
47
|
+
`.execute(db);
|
|
48
|
+
await sql`
|
|
49
|
+
alter table audit.effect
|
|
50
|
+
add constraint effect_tenant_id_fkey
|
|
51
|
+
foreign key (tenant_id) references public.tenant(id)
|
|
52
|
+
on delete cascade not valid;
|
|
53
|
+
`.execute(db);
|
|
54
|
+
await sql`
|
|
55
|
+
alter table audit.effect_attempt
|
|
56
|
+
add constraint effect_attempt_tenant_id_fkey
|
|
57
|
+
foreign key (tenant_id) references public.tenant(id)
|
|
58
|
+
on delete cascade not valid;
|
|
59
|
+
`.execute(db);
|
|
60
|
+
await sql`
|
|
61
|
+
alter table audit.journal_delta
|
|
62
|
+
add constraint journal_delta_tenant_id_fkey
|
|
63
|
+
foreign key (tenant_id) references public.tenant(id)
|
|
64
|
+
on delete cascade not valid;
|
|
65
|
+
`.execute(db);
|
|
66
|
+
}
|
package/package.json
CHANGED
|
File without changes
|