@nymphjs/driver-postgresql 1.0.0-beta.106 → 1.0.0-beta.108

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.
@@ -258,6 +258,14 @@ export default class PostgreSQLDriver extends NymphDriver {
258
258
  "tags" TEXT[],
259
259
  "cdate" DOUBLE PRECISION NOT NULL,
260
260
  "mdate" DOUBLE PRECISION NOT NULL,
261
+ "user" BYTEA,
262
+ "group" BYTEA,
263
+ "acUser" SMALLINT,
264
+ "acGroup" SMALLINT,
265
+ "acOther" SMALLINT,
266
+ "acRead" BYTEA[],
267
+ "acWrite" BYTEA[],
268
+ "acFull" BYTEA[],
261
269
  PRIMARY KEY ("guid")
262
270
  ) WITH ( OIDS=FALSE );`,
263
271
  { connection },
@@ -310,6 +318,7 @@ export default class PostgreSQLDriver extends NymphDriver {
310
318
  )} USING gin ("tags");`,
311
319
  { connection },
312
320
  );
321
+ await this.createEntitiesTilmeldIndexes(etype, connection);
313
322
  await this.queryRun(
314
323
  `ALTER TABLE ${PostgreSQLDriver.escape(
315
324
  `${this.prefix}entities_${etype}`,
@@ -318,6 +327,143 @@ export default class PostgreSQLDriver extends NymphDriver {
318
327
  );
319
328
  }
320
329
 
330
+ private async addTilmeldColumnsAndIndexes(
331
+ etype: string,
332
+ connection: PostgreSQLDriverConnection,
333
+ ) {
334
+ await this.queryRun(
335
+ `ALTER TABLE ${PostgreSQLDriver.escape(
336
+ `${this.prefix}entities_${etype}`,
337
+ )} ADD COLUMN IF NOT EXISTS "user" BYTEA,
338
+ ADD COLUMN IF NOT EXISTS "group" BYTEA,
339
+ ADD COLUMN IF NOT EXISTS "acUser" SMALLINT,
340
+ ADD COLUMN IF NOT EXISTS "acGroup" SMALLINT,
341
+ ADD COLUMN IF NOT EXISTS "acOther" SMALLINT,
342
+ ADD COLUMN IF NOT EXISTS "acRead" BYTEA[],
343
+ ADD COLUMN IF NOT EXISTS "acWrite" BYTEA[],
344
+ ADD COLUMN IF NOT EXISTS "acFull" BYTEA[];`,
345
+ );
346
+ await this.createEntitiesTilmeldIndexes(etype, connection);
347
+ }
348
+
349
+ private async createEntitiesTilmeldIndexes(
350
+ etype: string,
351
+ connection: PostgreSQLDriverConnection,
352
+ ) {
353
+ await this.queryRun(
354
+ `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
355
+ `${this.prefix}entities_${etype}_id_user_acUser`,
356
+ )};`,
357
+ { connection },
358
+ );
359
+ await this.queryRun(
360
+ `CREATE INDEX ${PostgreSQLDriver.escape(
361
+ `${this.prefix}entities_${etype}_id_user_acUser`,
362
+ )} ON ${PostgreSQLDriver.escape(
363
+ `${this.prefix}entities_${etype}`,
364
+ )} USING btree ("user", "acUser");`,
365
+ { connection },
366
+ );
367
+ await this.queryRun(
368
+ `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
369
+ `${this.prefix}entities_${etype}_id_group_acGroup`,
370
+ )};`,
371
+ { connection },
372
+ );
373
+ await this.queryRun(
374
+ `CREATE INDEX ${PostgreSQLDriver.escape(
375
+ `${this.prefix}entities_${etype}_id_group_acGroup`,
376
+ )} ON ${PostgreSQLDriver.escape(
377
+ `${this.prefix}entities_${etype}`,
378
+ )} USING btree ("group", "acGroup");`,
379
+ { connection },
380
+ );
381
+ await this.queryRun(
382
+ `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
383
+ `${this.prefix}entities_${etype}_id_acUser`,
384
+ )};`,
385
+ { connection },
386
+ );
387
+ await this.queryRun(
388
+ `CREATE INDEX ${PostgreSQLDriver.escape(
389
+ `${this.prefix}entities_${etype}_id_acUser`,
390
+ )} ON ${PostgreSQLDriver.escape(
391
+ `${this.prefix}entities_${etype}`,
392
+ )} USING btree ("acUser");`,
393
+ { connection },
394
+ );
395
+ await this.queryRun(
396
+ `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
397
+ `${this.prefix}entities_${etype}_id_acGroup`,
398
+ )};`,
399
+ { connection },
400
+ );
401
+ await this.queryRun(
402
+ `CREATE INDEX ${PostgreSQLDriver.escape(
403
+ `${this.prefix}entities_${etype}_id_acGroup`,
404
+ )} ON ${PostgreSQLDriver.escape(
405
+ `${this.prefix}entities_${etype}`,
406
+ )} USING btree ("acGroup");`,
407
+ { connection },
408
+ );
409
+ await this.queryRun(
410
+ `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
411
+ `${this.prefix}entities_${etype}_id_acOther`,
412
+ )};`,
413
+ { connection },
414
+ );
415
+ await this.queryRun(
416
+ `CREATE INDEX ${PostgreSQLDriver.escape(
417
+ `${this.prefix}entities_${etype}_id_acOther`,
418
+ )} ON ${PostgreSQLDriver.escape(
419
+ `${this.prefix}entities_${etype}`,
420
+ )} USING btree ("acOther");`,
421
+ { connection },
422
+ );
423
+ await this.queryRun(
424
+ `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
425
+ `${this.prefix}entities_${etype}_id_acRead`,
426
+ )};`,
427
+ { connection },
428
+ );
429
+ await this.queryRun(
430
+ `CREATE INDEX ${PostgreSQLDriver.escape(
431
+ `${this.prefix}entities_${etype}_id_acRead`,
432
+ )} ON ${PostgreSQLDriver.escape(
433
+ `${this.prefix}entities_${etype}`,
434
+ )} USING gin ("acRead");`,
435
+ { connection },
436
+ );
437
+ await this.queryRun(
438
+ `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
439
+ `${this.prefix}entities_${etype}_id_acWrite`,
440
+ )};`,
441
+ { connection },
442
+ );
443
+ await this.queryRun(
444
+ `CREATE INDEX ${PostgreSQLDriver.escape(
445
+ `${this.prefix}entities_${etype}_id_acWrite`,
446
+ )} ON ${PostgreSQLDriver.escape(
447
+ `${this.prefix}entities_${etype}`,
448
+ )} USING gin ("acWrite");`,
449
+ { connection },
450
+ );
451
+ await this.queryRun(
452
+ `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
453
+ `${this.prefix}entities_${etype}_id_acFull`,
454
+ )};`,
455
+ { connection },
456
+ );
457
+ await this.queryRun(
458
+ `CREATE INDEX ${PostgreSQLDriver.escape(
459
+ `${this.prefix}entities_${etype}_id_acFull`,
460
+ )} ON ${PostgreSQLDriver.escape(
461
+ `${this.prefix}entities_${etype}`,
462
+ )} USING gin ("acFull");`,
463
+ { connection },
464
+ );
465
+ }
466
+
321
467
  private async createDataTable(
322
468
  etype: string,
323
469
  connection: PostgreSQLDriverConnection,
@@ -2814,7 +2960,7 @@ export default class PostgreSQLDriver extends NymphDriver {
2814
2960
  sdata: SerializedEntityData;
2815
2961
  etype: string;
2816
2962
  }) {
2817
- return await this.importEntityInternal(entity, false);
2963
+ return await this.importEntityInternal(entity);
2818
2964
  }
2819
2965
 
2820
2966
  public async importEntityTokens(entity: {
@@ -2825,7 +2971,18 @@ export default class PostgreSQLDriver extends NymphDriver {
2825
2971
  sdata: SerializedEntityData;
2826
2972
  etype: string;
2827
2973
  }) {
2828
- return await this.importEntityInternal(entity, true);
2974
+ return await this.importEntityInternal(entity, { only: 'tokens' });
2975
+ }
2976
+
2977
+ public async importEntityTilmeldAC(entity: {
2978
+ guid: string;
2979
+ cdate: number;
2980
+ mdate: number;
2981
+ tags: string[];
2982
+ sdata: SerializedEntityData;
2983
+ etype: string;
2984
+ }) {
2985
+ return await this.importEntityInternal(entity, { only: 'tilmeldAC' });
2829
2986
  }
2830
2987
 
2831
2988
  private async importEntityInternal(
@@ -2844,11 +3001,11 @@ export default class PostgreSQLDriver extends NymphDriver {
2844
3001
  sdata: SerializedEntityData;
2845
3002
  etype: string;
2846
3003
  },
2847
- onlyTokens: boolean,
3004
+ { only = undefined }: { only?: 'tokens' | 'tilmeldAC' } = {},
2848
3005
  ) {
2849
3006
  try {
2850
3007
  let promises = [];
2851
- if (!onlyTokens) {
3008
+ if (only == null) {
2852
3009
  promises.push(
2853
3010
  this.queryRun(
2854
3011
  `DELETE FROM ${PostgreSQLDriver.escape(
@@ -2889,20 +3046,22 @@ export default class PostgreSQLDriver extends NymphDriver {
2889
3046
  ),
2890
3047
  );
2891
3048
  }
2892
- promises.push(
2893
- this.queryRun(
2894
- `DELETE FROM ${PostgreSQLDriver.escape(
2895
- `${this.prefix}tokens_${etype}`,
2896
- )} WHERE "guid"=decode(@guid, 'hex');`,
2897
- {
2898
- etypes: [etype],
2899
- params: {
2900
- guid,
3049
+ if (only == null || only === 'tokens') {
3050
+ promises.push(
3051
+ this.queryRun(
3052
+ `DELETE FROM ${PostgreSQLDriver.escape(
3053
+ `${this.prefix}tokens_${etype}`,
3054
+ )} WHERE "guid"=decode(@guid, 'hex');`,
3055
+ {
3056
+ etypes: [etype],
3057
+ params: {
3058
+ guid,
3059
+ },
2901
3060
  },
2902
- },
2903
- ),
2904
- );
2905
- if (!onlyTokens) {
3061
+ ),
3062
+ );
3063
+ }
3064
+ if (only == null) {
2906
3065
  promises.push(
2907
3066
  this.queryRun(
2908
3067
  `DELETE FROM ${PostgreSQLDriver.escape(
@@ -2921,11 +3080,14 @@ export default class PostgreSQLDriver extends NymphDriver {
2921
3080
  await Promise.all(promises);
2922
3081
  promises = [];
2923
3082
 
2924
- if (!onlyTokens) {
3083
+ if (only == null) {
3084
+ let { user, group, acUser, acGroup, acOther, acRead, acWrite, acFull } =
3085
+ this.removeAndReturnACValues(etype, {}, sdata);
3086
+
2925
3087
  await this.queryRun(
2926
3088
  `INSERT INTO ${PostgreSQLDriver.escape(
2927
3089
  `${this.prefix}entities_${etype}`,
2928
- )} ("guid", "tags", "cdate", "mdate") VALUES (decode(@guid, 'hex'), @tags, @cdate, @mdate);`,
3090
+ )} ("guid", "tags", "cdate", "mdate", "user", "group", "acUser", "acGroup", "acOther", "acRead", "acWrite", "acFull") VALUES (decode(@guid, 'hex'), @tags, @cdate, @mdate, ${user == null ? '@user' : "decode(@user, 'hex')"}, ${group == null ? '@group' : "decode(@group, 'hex')"}, @acUser, @acGroup, @acOther, ${!acRead?.length ? '@acRead' : "array(SELECT decode(n, 'hex') FROM unnest(@acRead::text[]) AS n)"}, ${!acWrite?.length ? '@acWrite' : "array(SELECT decode(n, 'hex') FROM unnest(@acWrite::text[]) AS n)"}, ${!acFull?.length ? '@acFull' : "array(SELECT decode(n, 'hex') FROM unnest(@acFull::text[]) AS n)"});`,
2929
3091
  {
2930
3092
  etypes: [etype],
2931
3093
  params: {
@@ -2933,6 +3095,14 @@ export default class PostgreSQLDriver extends NymphDriver {
2933
3095
  tags,
2934
3096
  cdate: isNaN(cdate) ? null : cdate,
2935
3097
  mdate: isNaN(mdate) ? null : mdate,
3098
+ user,
3099
+ group,
3100
+ acUser,
3101
+ acGroup,
3102
+ acOther,
3103
+ acRead,
3104
+ acWrite,
3105
+ acFull,
2936
3106
  },
2937
3107
  },
2938
3108
  );
@@ -2998,58 +3168,87 @@ export default class PostgreSQLDriver extends NymphDriver {
2998
3168
  }
2999
3169
  }
3000
3170
 
3171
+ if (only === 'tilmeldAC') {
3172
+ let { user, group, acUser, acGroup, acOther, acRead, acWrite, acFull } =
3173
+ this.removeAndReturnACValues(etype, {}, sdata);
3174
+
3175
+ promises.push(
3176
+ this.queryRun(
3177
+ `UPDATE ${PostgreSQLDriver.escape(
3178
+ `${this.prefix}entities_${etype}`,
3179
+ )} SET "user"=${user == null ? '@user' : "decode(@user, 'hex')"}, "group"=${group == null ? '@group' : "decode(@group, 'hex')"}, "acUser"=@acUser, "acGroup"=@acGroup, "acOther"=@acOther, "acRead"=${!acRead?.length ? '@acRead' : "array(SELECT decode(n, 'hex') FROM unnest(@acRead::text[]) AS n)"}, "acWrite"=${!acWrite?.length ? '@acWrite' : "array(SELECT decode(n, 'hex') FROM unnest(@acWrite::text[]) AS n)"}, "acFull"=${!acFull?.length ? '@acFull' : "array(SELECT decode(n, 'hex') FROM unnest(@acFull::text[]) AS n)"} WHERE "guid"=decode(@guid, 'hex');`,
3180
+ {
3181
+ etypes: [etype],
3182
+ params: {
3183
+ user,
3184
+ group,
3185
+ acUser,
3186
+ acGroup,
3187
+ acOther,
3188
+ acRead,
3189
+ acWrite,
3190
+ acFull,
3191
+ guid,
3192
+ },
3193
+ },
3194
+ ),
3195
+ );
3196
+ }
3197
+
3001
3198
  const EntityClass = this.nymph.getEntityClassByEtype(etype);
3002
3199
 
3003
- for (let name in sdata) {
3004
- let tokenString: string | null = null;
3005
- try {
3006
- tokenString = EntityClass.getFTSText(name, JSON.parse(sdata[name]));
3007
- } catch (e: any) {
3008
- // Ignore error.
3009
- }
3200
+ if (only == null || only === 'tokens') {
3201
+ for (let name in sdata) {
3202
+ let tokenString: string | null = null;
3203
+ try {
3204
+ tokenString = EntityClass.getFTSText(name, JSON.parse(sdata[name]));
3205
+ } catch (e: any) {
3206
+ // Ignore error.
3207
+ }
3010
3208
 
3011
- if (tokenString != null) {
3012
- const tokens = this.tokenizer.tokenize(tokenString);
3013
- while (tokens.length) {
3014
- const currentTokens = tokens.splice(0, 100);
3015
- const params: { [k: string]: any } = {
3016
- guid,
3017
- name,
3018
- };
3019
- const values: string[] = [];
3209
+ if (tokenString != null) {
3210
+ const tokens = this.tokenizer.tokenize(tokenString);
3211
+ while (tokens.length) {
3212
+ const currentTokens = tokens.splice(0, 100);
3213
+ const params: { [k: string]: any } = {
3214
+ guid,
3215
+ name,
3216
+ };
3217
+ const values: string[] = [];
3218
+
3219
+ for (let i = 0; i < currentTokens.length; i++) {
3220
+ const token = currentTokens[i];
3221
+ params['token' + i] = token.token;
3222
+ params['position' + i] = token.position;
3223
+ params['stem' + i] = token.stem;
3224
+ values.push(
3225
+ "(decode(@guid, 'hex'), @name, @token" +
3226
+ i +
3227
+ ', @position' +
3228
+ i +
3229
+ ', @stem' +
3230
+ i +
3231
+ ')',
3232
+ );
3233
+ }
3020
3234
 
3021
- for (let i = 0; i < currentTokens.length; i++) {
3022
- const token = currentTokens[i];
3023
- params['token' + i] = token.token;
3024
- params['position' + i] = token.position;
3025
- params['stem' + i] = token.stem;
3026
- values.push(
3027
- "(decode(@guid, 'hex'), @name, @token" +
3028
- i +
3029
- ', @position' +
3030
- i +
3031
- ', @stem' +
3032
- i +
3033
- ')',
3235
+ promises.push(
3236
+ this.queryRun(
3237
+ `INSERT INTO ${PostgreSQLDriver.escape(
3238
+ `${this.prefix}tokens_${etype}`,
3239
+ )} ("guid", "name", "token", "position", "stem") VALUES ${values.join(', ')};`,
3240
+ {
3241
+ etypes: [etype],
3242
+ params,
3243
+ },
3244
+ ),
3034
3245
  );
3035
3246
  }
3036
-
3037
- promises.push(
3038
- this.queryRun(
3039
- `INSERT INTO ${PostgreSQLDriver.escape(
3040
- `${this.prefix}tokens_${etype}`,
3041
- )} ("guid", "name", "token", "position", "stem") VALUES ${values.join(', ')};`,
3042
- {
3043
- etypes: [etype],
3044
- params,
3045
- },
3046
- ),
3047
- );
3048
3247
  }
3049
3248
  }
3050
3249
  }
3051
3250
 
3052
- if (!onlyTokens) {
3251
+ if (only == null) {
3053
3252
  const uniques = await EntityClass.getUniques({
3054
3253
  guid,
3055
3254
  cdate,
@@ -3384,16 +3583,34 @@ export default class PostgreSQLDriver extends NymphDriver {
3384
3583
  ) {
3385
3584
  return false;
3386
3585
  }
3586
+ let {
3587
+ user,
3588
+ group,
3589
+ acUser,
3590
+ acGroup,
3591
+ acOther,
3592
+ acRead,
3593
+ acWrite,
3594
+ acFull,
3595
+ } = this.removeAndReturnACValues(etype, data, sdata);
3387
3596
  await this.queryRun(
3388
3597
  `INSERT INTO ${PostgreSQLDriver.escape(
3389
3598
  `${this.prefix}entities_${etype}`,
3390
- )} ("guid", "tags", "cdate", "mdate") VALUES (decode(@guid, 'hex'), @tags, @cdate, @cdate);`,
3599
+ )} ("guid", "tags", "cdate", "mdate", "user", "group", "acUser", "acGroup", "acOther", "acRead", "acWrite", "acFull") VALUES (decode(@guid, 'hex'), @tags, @cdate, @cdate, ${user == null ? '@user' : "decode(@user, 'hex')"}, ${group == null ? '@group' : "decode(@group, 'hex')"}, @acUser, @acGroup, @acOther, ${!acRead?.length ? '@acRead' : "array(SELECT decode(n, 'hex') FROM unnest(@acRead::text[]) AS n)"}, ${!acWrite?.length ? '@acWrite' : "array(SELECT decode(n, 'hex') FROM unnest(@acWrite::text[]) AS n)"}, ${!acFull?.length ? '@acFull' : "array(SELECT decode(n, 'hex') FROM unnest(@acFull::text[]) AS n)"});`,
3391
3600
  {
3392
3601
  etypes: [etype],
3393
3602
  params: {
3394
3603
  guid,
3395
3604
  tags,
3396
3605
  cdate,
3606
+ user,
3607
+ group,
3608
+ acUser,
3609
+ acGroup,
3610
+ acOther,
3611
+ acRead,
3612
+ acWrite,
3613
+ acFull,
3397
3614
  },
3398
3615
  },
3399
3616
  );
@@ -3407,6 +3624,16 @@ export default class PostgreSQLDriver extends NymphDriver {
3407
3624
  ) {
3408
3625
  return false;
3409
3626
  }
3627
+ let {
3628
+ user,
3629
+ group,
3630
+ acUser,
3631
+ acGroup,
3632
+ acOther,
3633
+ acRead,
3634
+ acWrite,
3635
+ acFull,
3636
+ } = this.removeAndReturnACValues(etype, data, sdata);
3410
3637
  const promises = [];
3411
3638
  promises.push(
3412
3639
  this.queryRun(
@@ -3477,12 +3704,20 @@ export default class PostgreSQLDriver extends NymphDriver {
3477
3704
  const info = await this.queryRun(
3478
3705
  `UPDATE ${PostgreSQLDriver.escape(
3479
3706
  `${this.prefix}entities_${etype}`,
3480
- )} SET "tags"=@tags, "mdate"=@mdate WHERE "guid"=decode(@guid, 'hex') AND "mdate" <= @emdate;`,
3707
+ )} SET "tags"=@tags, "mdate"=@mdate, "user"=${user == null ? '@user' : "decode(@user, 'hex')"}, "group"=${group == null ? '@group' : "decode(@group, 'hex')"}, "acUser"=@acUser, "acGroup"=@acGroup, "acOther"=@acOther, "acRead"=${!acRead?.length ? '@acRead' : "array(SELECT decode(n, 'hex') FROM unnest(@acRead::text[]) AS n)"}, "acWrite"=${!acWrite?.length ? '@acWrite' : "array(SELECT decode(n, 'hex') FROM unnest(@acWrite::text[]) AS n)"}, "acFull"=${!acFull?.length ? '@acFull' : "array(SELECT decode(n, 'hex') FROM unnest(@acFull::text[]) AS n)"} WHERE "guid"=decode(@guid, 'hex') AND "mdate" <= @emdate;`,
3481
3708
  {
3482
3709
  etypes: [etype],
3483
3710
  params: {
3484
3711
  tags,
3485
3712
  mdate,
3713
+ user,
3714
+ group,
3715
+ acUser,
3716
+ acGroup,
3717
+ acOther,
3718
+ acRead,
3719
+ acWrite,
3720
+ acFull,
3486
3721
  guid,
3487
3722
  emdate: isNaN(Number(entity.mdate)) ? 0 : Number(entity.mdate),
3488
3723
  },
@@ -3650,7 +3885,9 @@ export default class PostgreSQLDriver extends NymphDriver {
3650
3885
  return nymph;
3651
3886
  }
3652
3887
 
3653
- public async needsMigration(): Promise<'json' | 'tokens' | false> {
3888
+ public async needsMigration(): Promise<
3889
+ 'json' | 'tokens' | 'tilmeldColumns' | false
3890
+ > {
3654
3891
  const table = await this.queryGet(
3655
3892
  'SELECT "table_name" AS "table_name" FROM "information_schema"."tables" WHERE "table_catalog"=@db AND "table_schema"=\'public\' AND "table_name" LIKE @prefix LIMIT 1;',
3656
3893
  {
@@ -3686,16 +3923,49 @@ export default class PostgreSQLDriver extends NymphDriver {
3686
3923
  if (!table2 || !table2.table_name) {
3687
3924
  return 'tokens';
3688
3925
  }
3926
+ const table3 = await this.queryGet(
3927
+ 'SELECT "table_name" AS "table_name" FROM "information_schema"."tables" WHERE "table_catalog"=@db AND "table_schema"=\'public\' AND "table_name" LIKE @prefix LIMIT 1;',
3928
+ {
3929
+ params: {
3930
+ db: this.config.database,
3931
+ prefix: this.prefix + 'entities_' + '%',
3932
+ },
3933
+ },
3934
+ );
3935
+ if (table3?.name) {
3936
+ const result = await this.queryGet(
3937
+ 'SELECT 1 AS "exists" FROM "information_schema"."columns" WHERE "table_catalog"=@db AND "table_schema"=\'public\' AND "table_name"=@table AND "column_name"=\'user\';',
3938
+ {
3939
+ params: {
3940
+ db: this.config.database,
3941
+ table: table3.table_name,
3942
+ },
3943
+ },
3944
+ );
3945
+ if (!result?.exists) {
3946
+ return 'tilmeldColumns';
3947
+ }
3948
+ }
3689
3949
  return false;
3690
3950
  }
3691
3951
 
3692
- public async liveMigration(_migrationType: 'tokenTables') {
3693
- const etypes = await this.getEtypes();
3952
+ public async liveMigration(migrationType: 'tokenTables' | 'tilmeldColumns') {
3953
+ if (migrationType === 'tokenTables') {
3954
+ const etypes = await this.getEtypes();
3694
3955
 
3695
- const connection = await this.getConnection(true);
3696
- for (let etype of etypes) {
3697
- await this.createTokensTable(etype, connection);
3956
+ const connection = await this.getConnection(true);
3957
+ for (let etype of etypes) {
3958
+ await this.createTokensTable(etype, connection);
3959
+ }
3960
+ connection.done();
3961
+ } else if (migrationType === 'tilmeldColumns') {
3962
+ const etypes = await this.getEtypes();
3963
+
3964
+ const connection = await this.getConnection(true);
3965
+ for (let etype of etypes) {
3966
+ await this.addTilmeldColumnsAndIndexes(etype, connection);
3967
+ }
3968
+ connection.done();
3698
3969
  }
3699
- connection.done();
3700
3970
  }
3701
3971
  }