@vrplatform/kysely 1.3.45-38030999894 → 1.3.45-38035169199

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,35 @@
1
+ import { type Kysely, sql } from 'kysely';
2
+
3
+ const original = `effect.effect_type = 'REFRESH_RESERVATION_JOURNAL'
4
+ and effect.entity_type = 'reservation'`;
5
+ const corrected = `effect.effect_type in (
6
+ 'REFRESH_RESERVATION_JOURNAL',
7
+ 'REFRESH_RECURRING_FEE_RESERVATIONS'
8
+ )
9
+ and effect.entity_type in ('reservation', 'recurringFee')`;
10
+
11
+ async function replaceProjectedEffects<Database>(
12
+ db: Kysely<Database>,
13
+ before: string,
14
+ after: string
15
+ ) {
16
+ const { rows } = await sql<{ definition: string }>`
17
+ select pg_get_functiondef('core.refresh_audit_action_source(uuid)'::regprocedure)
18
+ as definition
19
+ `.execute(db);
20
+ const definition = rows[0]?.definition;
21
+ if (!definition || definition.split(before).length !== 2) {
22
+ throw new Error(
23
+ 'Journal operation source projection has an unexpected definition'
24
+ );
25
+ }
26
+ await sql.raw(definition.replace(before, after)).execute(db);
27
+ }
28
+
29
+ export async function up<Database>(db: Kysely<Database>): Promise<void> {
30
+ await replaceProjectedEffects(db, original, corrected);
31
+ }
32
+
33
+ export async function down<Database>(db: Kysely<Database>): Promise<void> {
34
+ await replaceProjectedEffects(db, corrected, original);
35
+ }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.3.45-38030999894",
6
+ "version": "1.3.45-38035169199",
7
7
  "description": "",
8
8
  "main": "build/main/index.js",
9
9
  "module": "build/module/index.js",