@rotorsoft/act-pg 1.13.15 → 1.13.17

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/dist/index.js CHANGED
@@ -239,6 +239,9 @@ var PostgresStore = class {
239
239
  const client = await this._client("seed");
240
240
  try {
241
241
  await client.query("BEGIN");
242
+ await client.query(`SELECT pg_advisory_xact_lock(hashtext($1))`, [
243
+ this.config.schema
244
+ ]);
242
245
  await client.query(`SELECT pg_advisory_xact_lock(hashtext($1))`, [
243
246
  `${this.config.schema}.${this.config.table}`
244
247
  ]);
@@ -248,9 +251,9 @@ var PostgresStore = class {
248
251
  await client.query(
249
252
  `CREATE TABLE IF NOT EXISTS ${this._fqt} (
250
253
  id serial PRIMARY KEY,
251
- name varchar(100) COLLATE pg_catalog."default" NOT NULL,
254
+ name text COLLATE pg_catalog."default" NOT NULL,
252
255
  data jsonb,
253
- stream varchar(100) COLLATE pg_catalog."default" NOT NULL,
256
+ stream text COLLATE pg_catalog."default" NOT NULL,
254
257
  version int NOT NULL,
255
258
  created timestamptz NOT NULL DEFAULT now(),
256
259
  meta jsonb,
@@ -283,8 +286,8 @@ var PostgresStore = class {
283
286
  );
284
287
  await client.query(
285
288
  `CREATE TABLE IF NOT EXISTS ${this._fqs} (
286
- stream varchar(100) COLLATE pg_catalog."default" PRIMARY KEY,
287
- source varchar(100) COLLATE pg_catalog."default",
289
+ stream text COLLATE pg_catalog."default" PRIMARY KEY,
290
+ source text COLLATE pg_catalog."default",
288
291
  at int NOT NULL DEFAULT -1,
289
292
  retry int NOT NULL DEFAULT -1,
290
293
  blocked boolean NOT NULL DEFAULT false,
@@ -323,6 +326,28 @@ var PostgresStore = class {
323
326
  END
324
327
  $$;`
325
328
  );
329
+ for (const [table, columns] of [
330
+ [this.config.table, ["stream", "name"]],
331
+ [`${this.config.table}_streams`, ["stream", "source"]]
332
+ ]) {
333
+ for (const column of columns) {
334
+ await client.query(
335
+ `DO $$
336
+ BEGIN
337
+ IF EXISTS (
338
+ SELECT 1 FROM information_schema.columns
339
+ WHERE table_schema = '${this.config.schema}'
340
+ AND table_name = '${table}'
341
+ AND column_name = '${column}'
342
+ AND data_type = 'character varying'
343
+ ) THEN
344
+ EXECUTE 'ALTER TABLE "${this.config.schema}"."${table}" ALTER COLUMN ${column} TYPE text';
345
+ END IF;
346
+ END
347
+ $$;`
348
+ );
349
+ }
350
+ }
326
351
  await client.query(
327
352
  `DROP INDEX IF EXISTS "${this.config.schema}"."${this.config.table}_streams_fetch_ix"`
328
353
  );