@rotorsoft/act-pg 1.13.14 → 1.13.16
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/README.md +4 -2
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/postgres-store.d.ts.map +1 -1
- package/dist/index.cjs +29 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -6
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -248,9 +248,9 @@ var PostgresStore = class {
|
|
|
248
248
|
await client.query(
|
|
249
249
|
`CREATE TABLE IF NOT EXISTS ${this._fqt} (
|
|
250
250
|
id serial PRIMARY KEY,
|
|
251
|
-
name
|
|
251
|
+
name text COLLATE pg_catalog."default" NOT NULL,
|
|
252
252
|
data jsonb,
|
|
253
|
-
stream
|
|
253
|
+
stream text COLLATE pg_catalog."default" NOT NULL,
|
|
254
254
|
version int NOT NULL,
|
|
255
255
|
created timestamptz NOT NULL DEFAULT now(),
|
|
256
256
|
meta jsonb,
|
|
@@ -283,8 +283,8 @@ var PostgresStore = class {
|
|
|
283
283
|
);
|
|
284
284
|
await client.query(
|
|
285
285
|
`CREATE TABLE IF NOT EXISTS ${this._fqs} (
|
|
286
|
-
stream
|
|
287
|
-
source
|
|
286
|
+
stream text COLLATE pg_catalog."default" PRIMARY KEY,
|
|
287
|
+
source text COLLATE pg_catalog."default",
|
|
288
288
|
at int NOT NULL DEFAULT -1,
|
|
289
289
|
retry int NOT NULL DEFAULT -1,
|
|
290
290
|
blocked boolean NOT NULL DEFAULT false,
|
|
@@ -323,6 +323,28 @@ var PostgresStore = class {
|
|
|
323
323
|
END
|
|
324
324
|
$$;`
|
|
325
325
|
);
|
|
326
|
+
for (const [table, columns] of [
|
|
327
|
+
[this.config.table, ["stream", "name"]],
|
|
328
|
+
[`${this.config.table}_streams`, ["stream", "source"]]
|
|
329
|
+
]) {
|
|
330
|
+
for (const column of columns) {
|
|
331
|
+
await client.query(
|
|
332
|
+
`DO $$
|
|
333
|
+
BEGIN
|
|
334
|
+
IF EXISTS (
|
|
335
|
+
SELECT 1 FROM information_schema.columns
|
|
336
|
+
WHERE table_schema = '${this.config.schema}'
|
|
337
|
+
AND table_name = '${table}'
|
|
338
|
+
AND column_name = '${column}'
|
|
339
|
+
AND data_type = 'character varying'
|
|
340
|
+
) THEN
|
|
341
|
+
EXECUTE 'ALTER TABLE "${this.config.schema}"."${table}" ALTER COLUMN ${column} TYPE text';
|
|
342
|
+
END IF;
|
|
343
|
+
END
|
|
344
|
+
$$;`
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
326
348
|
await client.query(
|
|
327
349
|
`DROP INDEX IF EXISTS "${this.config.schema}"."${this.config.table}_streams_fetch_ix"`
|
|
328
350
|
);
|
|
@@ -1419,9 +1441,10 @@ var PostgresStore = class {
|
|
|
1419
1441
|
this._fqt
|
|
1420
1442
|
]);
|
|
1421
1443
|
const result = /* @__PURE__ */ new Map();
|
|
1422
|
-
|
|
1444
|
+
const retired = full.filter((t) => t.snapshot === void 0).map((t) => t.stream);
|
|
1445
|
+
if (retired.length) {
|
|
1423
1446
|
await client.query(`DELETE FROM ${this._fqs} WHERE stream = ANY($1)`, [
|
|
1424
|
-
|
|
1447
|
+
retired
|
|
1425
1448
|
]);
|
|
1426
1449
|
}
|
|
1427
1450
|
for (const { stream, snapshot, meta } of full) {
|