@vrplatform/kysely 1.3.45-stage.392 → 1.3.45-stage.423
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, sql } from 'kysely';
|
|
2
|
+
|
|
3
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
4
|
+
// Preserve the source lifecycle and failure precedence; ID format is not a failure policy.
|
|
5
|
+
await sql`
|
|
6
|
+
do $$
|
|
7
|
+
declare
|
|
8
|
+
definition text;
|
|
9
|
+
begin
|
|
10
|
+
definition := pg_get_functiondef('core.refresh_operation_state(uuid)'::regprocedure);
|
|
11
|
+
if position('and target_public_id_format = ''action''' in definition) = 0 then
|
|
12
|
+
raise exception 'Journal operation failure projection has an unexpected definition';
|
|
13
|
+
end if;
|
|
14
|
+
execute replace(definition, 'and target_public_id_format = ''action''', '');
|
|
15
|
+
end;
|
|
16
|
+
$$
|
|
17
|
+
`.execute(db);
|
|
18
|
+
|
|
19
|
+
await sql`
|
|
20
|
+
select core.refresh_operation_state(operation.id)
|
|
21
|
+
from core.operation as operation
|
|
22
|
+
where operation.type = 'reservation-journal-refresh'
|
|
23
|
+
and operation.public_id_format = 'legacy'
|
|
24
|
+
and operation.status = 'failed'
|
|
25
|
+
and exists (
|
|
26
|
+
select 1 from core.operation_source as source
|
|
27
|
+
where source.operation_id = operation.id
|
|
28
|
+
and source.source_type = 'audit-action'
|
|
29
|
+
)
|
|
30
|
+
`.execute(db);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
34
|
+
await sql`
|
|
35
|
+
do $$
|
|
36
|
+
declare
|
|
37
|
+
definition text;
|
|
38
|
+
begin
|
|
39
|
+
definition := pg_get_functiondef('core.refresh_operation_state(uuid)'::regprocedure);
|
|
40
|
+
if position('and target_public_id_format = ''action''' in definition) > 0
|
|
41
|
+
or position('and target_action_id is not null then' in definition) = 0 then
|
|
42
|
+
raise exception 'Journal operation failure projection has an unexpected definition';
|
|
43
|
+
end if;
|
|
44
|
+
execute replace(
|
|
45
|
+
definition,
|
|
46
|
+
'and target_action_id is not null then',
|
|
47
|
+
'and target_public_id_format = ''action'' and target_action_id is not null then'
|
|
48
|
+
);
|
|
49
|
+
end;
|
|
50
|
+
$$
|
|
51
|
+
`.execute(db);
|
|
52
|
+
|
|
53
|
+
await sql`
|
|
54
|
+
select core.refresh_operation_state(operation.id)
|
|
55
|
+
from core.operation as operation
|
|
56
|
+
where operation.type = 'reservation-journal-refresh'
|
|
57
|
+
and operation.public_id_format = 'legacy'
|
|
58
|
+
and operation.status = 'failed'
|
|
59
|
+
`.execute(db);
|
|
60
|
+
}
|