@vrplatform/kysely 1.3.45-stage.4374 → 1.3.45-stage.4376
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,40 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import { sql } from 'kysely';
|
|
3
|
+
|
|
4
|
+
// PRO-16537 part 1/2: tenant.status represents activity only
|
|
5
|
+
// (active | inactive). Onboarding state lives on is_onboarding; 'deleted'
|
|
6
|
+
// rows are legacy data (the delete flow hard-deletes the row) and read as
|
|
7
|
+
// inactive. The DDL (default + constraint) lives in the next migration —
|
|
8
|
+
// tenant has AFTER triggers, so DML and ALTER TABLE cannot share one
|
|
9
|
+
// transaction.
|
|
10
|
+
export async function up(db: Kysely<any>): Promise<void> {
|
|
11
|
+
// Hasura notify triggers on tenant leave pending trigger events that block
|
|
12
|
+
// the follow-up ALTER TABLE in the same migration transaction; a data-only
|
|
13
|
+
// backfill should not emit events anyway.
|
|
14
|
+
await sql`
|
|
15
|
+
alter table public.tenant disable trigger user;
|
|
16
|
+
`.execute(db);
|
|
17
|
+
await sql`
|
|
18
|
+
update public.tenant
|
|
19
|
+
set status = 'active', is_onboarding = true
|
|
20
|
+
where status = 'onboarding';
|
|
21
|
+
`.execute(db);
|
|
22
|
+
await sql`
|
|
23
|
+
update public.tenant
|
|
24
|
+
set status = 'inactive'
|
|
25
|
+
where status = 'deleted';
|
|
26
|
+
`.execute(db);
|
|
27
|
+
await sql`
|
|
28
|
+
update public.tenant
|
|
29
|
+
set status = 'active'
|
|
30
|
+
where status is null;
|
|
31
|
+
`.execute(db);
|
|
32
|
+
await sql`
|
|
33
|
+
alter table public.tenant enable trigger user;
|
|
34
|
+
`.execute(db);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export async function down(): Promise<void> {
|
|
38
|
+
// Backfill is not reversible; the legacy statuses carry no extra
|
|
39
|
+
// information worth restoring.
|
|
40
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import { sql } from 'kysely';
|
|
3
|
+
|
|
4
|
+
// PRO-16537 part 2/2: default to active and reject anything outside
|
|
5
|
+
// active | inactive (see 0000000000047-tenant-status-backfill).
|
|
6
|
+
export async function up(db: Kysely<any>): Promise<void> {
|
|
7
|
+
await sql`
|
|
8
|
+
alter table public.tenant alter column status set default 'active';
|
|
9
|
+
`.execute(db);
|
|
10
|
+
await sql`
|
|
11
|
+
alter table public.tenant
|
|
12
|
+
add constraint tenant_status_check
|
|
13
|
+
check (status is not null and status in ('active', 'inactive'));
|
|
14
|
+
`.execute(db);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function down(db: Kysely<any>): Promise<void> {
|
|
18
|
+
await sql`
|
|
19
|
+
alter table public.tenant drop constraint if exists tenant_status_check;
|
|
20
|
+
`.execute(db);
|
|
21
|
+
await sql`
|
|
22
|
+
alter table public.tenant alter column status set default 'onboarding';
|
|
23
|
+
`.execute(db);
|
|
24
|
+
}
|