@rebasepro/server-postgres 0.23.0 → 0.24.1-canary.g19596ef
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 +16 -0
- package/dist/{BranchService-DGPL6G_C.js → BranchService-UgKa416x.js} +47 -19
- package/dist/BranchService-UgKa416x.js.map +1 -0
- package/dist/PostgresBackendDriver.d.ts +187 -13
- package/dist/PostgresBootstrapper.d.ts +101 -2
- package/dist/auth/ensure-tables.d.ts +12 -0
- package/dist/auth/services.d.ts +78 -14
- package/dist/{auth-users-columns-D2LBFrMH.js → auth-users-columns-C72EMoDJ.js} +17 -1
- package/dist/{auth-users-columns-D2LBFrMH.js.map → auth-users-columns-C72EMoDJ.js.map} +1 -1
- package/dist/backup/backup-cli.d.ts +75 -2
- package/dist/backup/backup-service.d.ts +2 -2
- package/dist/backup/pg-binary.d.ts +5 -0
- package/dist/{backup-cli-24v4OlSp.js → backup-cli-yiKd1GsC.js} +168 -75
- package/dist/backup-cli-yiKd1GsC.js.map +1 -0
- package/dist/{backup-service-HQ9GC4tN.js → backup-service-AZWc2wvI.js} +104 -35
- package/dist/backup-service-AZWc2wvI.js.map +1 -0
- package/dist/boot-ddl-B9ZmBJ75.js +105 -0
- package/dist/boot-ddl-B9ZmBJ75.js.map +1 -0
- package/dist/cli-console-DGee3Zl7.js +225 -0
- package/dist/cli-console-DGee3Zl7.js.map +1 -0
- package/dist/cli-console.d.ts +39 -0
- package/dist/cli-errors-oVUuD8k0.js +2180 -0
- package/dist/cli-errors-oVUuD8k0.js.map +1 -0
- package/dist/cli-errors.d.ts +133 -9
- package/dist/{cli-flags-BglvpjHv.js → cli-flags-DnPHXjRH.js} +56 -6
- package/dist/cli-flags-DnPHXjRH.js.map +1 -0
- package/dist/cli-flags.d.ts +15 -0
- package/dist/cli-helpers.d.ts +88 -34
- package/dist/cli-output.d.ts +16 -28
- package/dist/{arg-Dni7MzLB.js → cli-prompt-egtNKkZl.js} +49 -3
- package/dist/cli-prompt-egtNKkZl.js.map +1 -0
- package/dist/cli-prompt.d.ts +19 -0
- package/dist/cli-push.d.ts +87 -0
- package/dist/cli-scratch-database.d.ts +33 -8
- package/dist/cli.js +826 -230
- package/dist/cli.js.map +1 -1
- package/dist/{column-plan-helpers-DF-8dTVa.js → column-plan-helpers-D_V4oaZh.js} +43 -27
- package/dist/column-plan-helpers-D_V4oaZh.js.map +1 -0
- package/dist/{databasePoolManager-Bj5FbeAs.js → connection-C938nR3E.js} +25 -113
- package/dist/connection-C938nR3E.js.map +1 -0
- package/dist/connection.d.ts +13 -2
- package/dist/data-transformer.d.ts +0 -8
- package/dist/databasePoolManager-DZgnBOgj.js +119 -0
- package/dist/databasePoolManager-DZgnBOgj.js.map +1 -0
- package/dist/deferred-index-build-BqmEHGaD.js +1051 -0
- package/dist/deferred-index-build-BqmEHGaD.js.map +1 -0
- package/dist/{doctor-Cb2thZ8s.js → doctor-CUAAOFZm.js} +281 -89
- package/dist/doctor-CUAAOFZm.js.map +1 -0
- package/dist/ensure-collection-policies-Bb51V2OV.js +541 -0
- package/dist/ensure-collection-policies-Bb51V2OV.js.map +1 -0
- package/dist/ensure-collection-tables-egjGBjhv.js +532 -0
- package/dist/ensure-collection-tables-egjGBjhv.js.map +1 -0
- package/dist/{ensure-tables-Dhn9KM3B.js → ensure-tables-DMPWhJ6R.js} +180 -77
- package/dist/ensure-tables-DMPWhJ6R.js.map +1 -0
- package/dist/enum-labels-kept-Msq5gMcb.js +56 -0
- package/dist/enum-labels-kept-Msq5gMcb.js.map +1 -0
- package/dist/generate-drizzle-schema-DrA-YgXv.js +57 -0
- package/dist/generate-drizzle-schema-DrA-YgXv.js.map +1 -0
- package/dist/{generate-drizzle-schema-logic-BfzK7UQd.js → generate-drizzle-schema-logic-BaT0H7Gq.js} +29 -11
- package/dist/generate-drizzle-schema-logic-BaT0H7Gq.js.map +1 -0
- package/dist/generate-files-OoRJLEdk.js +199 -0
- package/dist/generate-files-OoRJLEdk.js.map +1 -0
- package/dist/generate-postgres-ddl-logic-B4k9djAV.js +152 -0
- package/dist/generate-postgres-ddl-logic-B4k9djAV.js.map +1 -0
- package/dist/{generated-schema-staleness-Di9c4ZxN.js → generated-schema-staleness-BWN_PsMi.js} +2 -2
- package/dist/{generated-schema-staleness-Di9c4ZxN.js.map → generated-schema-staleness-BWN_PsMi.js.map} +1 -1
- package/dist/generated-sql.d.ts +34 -0
- package/dist/history/HistoryService.d.ts +64 -5
- package/dist/history/ensure-history-table.d.ts +63 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +139 -16738
- package/dist/index.es.js.map +1 -1
- package/dist/{introspect-db-logic-WMuAfxvw.js → introspect-db-logic-BCc1Jym2.js} +654 -353
- package/dist/introspect-db-logic-BCc1Jym2.js.map +1 -0
- package/dist/introspect-db-queries-BhhJg0b8.js +364 -0
- package/dist/introspect-db-queries-BhhJg0b8.js.map +1 -0
- package/dist/open-rebase-CAjWpPjs.js +20895 -0
- package/dist/open-rebase-CAjWpPjs.js.map +1 -0
- package/dist/open-rebase.d.ts +94 -0
- package/dist/pg-error-utils-Bs_Ue4wn.js +395 -0
- package/dist/pg-error-utils-Bs_Ue4wn.js.map +1 -0
- package/dist/{plan-schema-C0fxM8dY.js → plan-schema-CsNgK0qi.js} +279 -534
- package/dist/plan-schema-CsNgK0qi.js.map +1 -0
- package/dist/{policy-drift-DljYdrpW.js → policy-drift-BKC50y2p.js} +33 -9
- package/dist/policy-drift-BKC50y2p.js.map +1 -0
- package/dist/push-index-prebuild-C_qhyoJa.js +45 -0
- package/dist/push-index-prebuild-C_qhyoJa.js.map +1 -0
- package/dist/push-legacy-renames-5g9h3HOa.js +34 -0
- package/dist/push-legacy-renames-5g9h3HOa.js.map +1 -0
- package/dist/{generate-postgres-ddl-logic-Bt2d2mRH.js → render-ddl-CrfEe__B.js} +24 -157
- package/dist/render-ddl-CrfEe__B.js.map +1 -0
- package/dist/{rls-bootstrap-sql-B8EclDyM.js → rls-bootstrap-sql-Bd-hJk08.js} +125 -1101
- package/dist/rls-bootstrap-sql-Bd-hJk08.js.map +1 -0
- package/dist/{rls-enforcement-C6Xk0lA6.js → rls-enforcement-D7P4-ZYX.js} +138 -18
- package/dist/rls-enforcement-D7P4-ZYX.js.map +1 -0
- package/dist/{__vite-browser-external-BnuHet1e.js → rolldown-runtime-V7rFbMRe.js} +1 -8
- package/dist/schema/atlas-exclude.d.ts +42 -0
- package/dist/schema/auth-schema.d.ts +172 -2
- package/dist/schema/boot-ddl.d.ts +47 -0
- package/dist/schema/carved-out-migration.d.ts +5 -4
- package/dist/schema/classify-change.d.ts +29 -1
- package/dist/schema/collection-index.d.ts +45 -0
- package/dist/schema/column-plan-helpers.d.ts +38 -21
- package/dist/schema/deferred-index-build.d.ts +131 -0
- package/dist/schema/destructive-sql.d.ts +50 -2
- package/dist/schema/doctor-cli.js +110 -6
- package/dist/schema/doctor-cli.js.map +1 -1
- package/dist/schema/doctor-search-scale.d.ts +45 -0
- package/dist/schema/doctor.d.ts +53 -1
- package/dist/schema/ensure-collection-policies.d.ts +95 -35
- package/dist/schema/ensure-collection-tables.d.ts +56 -3
- package/dist/schema/enum-labels-kept.d.ts +26 -0
- package/dist/schema/generate-drizzle-schema.js +1 -1
- package/dist/schema/generate-files.d.ts +44 -0
- package/dist/schema/generate-next-step.d.ts +0 -13
- package/dist/schema/generate-postgres-ddl-logic.d.ts +5 -5
- package/dist/schema/generate-postgres-ddl.js +10 -81
- package/dist/schema/generate-postgres-ddl.js.map +1 -1
- package/dist/schema/generate-schema-commit.d.ts +12 -0
- package/dist/schema/generated-schema-diff.d.ts +7 -0
- package/dist/schema/introspect-db-logic.d.ts +63 -0
- package/dist/schema/introspect-db-queries.d.ts +21 -2
- package/dist/schema/introspect-db-search.d.ts +22 -0
- package/dist/schema/introspect-db-storage.d.ts +83 -0
- package/dist/schema/introspect-db-structure.d.ts +10 -0
- package/dist/schema/introspect-db.js +29 -21
- package/dist/schema/introspect-db.js.map +1 -1
- package/dist/schema/migrate-baseline.d.ts +33 -0
- package/dist/schema/migration-post-process.d.ts +34 -0
- package/dist/schema/plan/diff-plan.d.ts +127 -1
- package/dist/schema/plan/plan-schema.d.ts +16 -8
- package/dist/schema/plan/render-ddl.d.ts +8 -1
- package/dist/schema/plan/types.d.ts +45 -11
- package/dist/schema/push-index-prebuild.d.ts +25 -0
- package/dist/schema/push-legacy-renames.d.ts +20 -0
- package/dist/schema/rls-bootstrap-sql.d.ts +15 -0
- package/dist/schema/undeclarable-constraints.d.ts +59 -0
- package/dist/search-column-BM-GV6vH.js +442 -0
- package/dist/search-column-BM-GV6vH.js.map +1 -0
- package/dist/security/policy-drift.d.ts +1 -1
- package/dist/security/rls-enforcement.d.ts +39 -4
- package/dist/services/BranchService.d.ts +29 -1
- package/dist/services/FetchService.d.ts +63 -12
- package/dist/services/PersistService.d.ts +15 -0
- package/dist/services/RelationService.d.ts +106 -3
- package/dist/services/cdc/CdcListener.d.ts +26 -10
- package/dist/services/cdc/identity-columns.d.ts +19 -0
- package/dist/services/cdc/trigger-cdc.d.ts +180 -18
- package/dist/services/channel-bus/PostgresChannelBus.d.ts +12 -7
- package/dist/services/channel-bus/index.d.ts +1 -1
- package/dist/services/channel-history.d.ts +32 -5
- package/dist/services/collection-helpers.d.ts +26 -1
- package/dist/services/field-viewer.d.ts +15 -1
- package/dist/services/pg-notify-listener.d.ts +95 -6
- package/dist/services/realtimeService.d.ts +467 -53
- package/dist/services/row-pipeline.d.ts +16 -9
- package/dist/services/socket-liveness.d.ts +85 -0
- package/dist/services/soft-delete.d.ts +12 -0
- package/dist/services/sql-script.d.ts +275 -0
- package/dist/services/vector-iterative-scan.d.ts +40 -0
- package/dist/services/write-depth.d.ts +22 -0
- package/dist/services/write-transaction-scope.d.ts +15 -3
- package/dist/socket-opt-ins.d.ts +64 -0
- package/dist/source-DB6xJv3p.js +873 -0
- package/dist/source-DB6xJv3p.js.map +1 -0
- package/dist/tsx-loader.d.ts +14 -0
- package/dist/utils/connection-string.d.ts +31 -0
- package/dist/utils/drizzle-conditions.d.ts +63 -3
- package/dist/utils/error-cause.d.ts +7 -0
- package/dist/utils/pg-error-utils.d.ts +2 -4
- package/dist/utils/result-rows.d.ts +10 -0
- package/dist/{vector-index-CMJKb3C9.js → vector-index-BFhyEaiz.js} +2 -2
- package/dist/{vector-index-CMJKb3C9.js.map → vector-index-BFhyEaiz.js.map} +1 -1
- package/dist/websocket-DUiiwQd2.js +1632 -0
- package/dist/websocket-DUiiwQd2.js.map +1 -0
- package/dist/websocket.d.ts +63 -18
- package/package.json +7 -7
- package/dist/BranchService-DGPL6G_C.js.map +0 -1
- package/dist/__vite-browser-external-BnuHet1e.js.map +0 -1
- package/dist/arg-Dni7MzLB.js.map +0 -1
- package/dist/backup-cli-24v4OlSp.js.map +0 -1
- package/dist/backup-service-HQ9GC4tN.js.map +0 -1
- package/dist/cli-errors-B8qHg02P.js +0 -798
- package/dist/cli-errors-B8qHg02P.js.map +0 -1
- package/dist/cli-flags-BglvpjHv.js.map +0 -1
- package/dist/cli-output-CNdMql-L.js +0 -47
- package/dist/cli-output-CNdMql-L.js.map +0 -1
- package/dist/collection-index-DdnsxiJ_.js +0 -286
- package/dist/collection-index-DdnsxiJ_.js.map +0 -1
- package/dist/column-plan-helpers-DF-8dTVa.js.map +0 -1
- package/dist/databasePoolManager-Bj5FbeAs.js.map +0 -1
- package/dist/doctor-Cb2thZ8s.js.map +0 -1
- package/dist/ensure-collection-policies-RHUcEp4v.js +0 -105
- package/dist/ensure-collection-policies-RHUcEp4v.js.map +0 -1
- package/dist/ensure-collection-tables-BEEjn5cn.js +0 -857
- package/dist/ensure-collection-tables-BEEjn5cn.js.map +0 -1
- package/dist/ensure-tables-Dhn9KM3B.js.map +0 -1
- package/dist/generate-drizzle-schema-logic-BfzK7UQd.js.map +0 -1
- package/dist/generate-drizzle-schema-yzY_BLhr.js +0 -123
- package/dist/generate-drizzle-schema-yzY_BLhr.js.map +0 -1
- package/dist/generate-postgres-ddl-logic-Bt2d2mRH.js.map +0 -1
- package/dist/introspect-db-logic-WMuAfxvw.js.map +0 -1
- package/dist/plan-schema-C0fxM8dY.js.map +0 -1
- package/dist/policy-drift-DljYdrpW.js.map +0 -1
- package/dist/rls-bootstrap-sql-B8EclDyM.js.map +0 -1
- package/dist/rls-enforcement-C6Xk0lA6.js.map +0 -1
- package/dist/source-Br7L7GOI.js +0 -410
- package/dist/source-Br7L7GOI.js.map +0 -1
|
@@ -2,12 +2,15 @@ import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
|
2
2
|
import type { EntityHistoryEntry } from "@rebasepro/types";
|
|
3
3
|
export type { RecordHistoryParams, FetchHistoryOptions, HistoryRetentionConfig } from "@rebasepro/types";
|
|
4
4
|
import type { RecordHistoryParams, FetchHistoryOptions, HistoryRetentionConfig } from "@rebasepro/types";
|
|
5
|
+
import { type HistoryTableState } from "./ensure-history-table.js";
|
|
5
6
|
/**
|
|
6
7
|
* A Postgres history row is already the wire shape — `updated_at` comes back
|
|
7
8
|
* from the driver as a string. Kept as an alias because the name is used
|
|
8
9
|
* throughout this package and in `PostgresBackendDriver`.
|
|
9
10
|
*/
|
|
10
11
|
export type HistoryEntry = EntityHistoryEntry;
|
|
12
|
+
/** Entries one statement of {@link HistoryService.pruneExpired} deletes at most. */
|
|
13
|
+
export declare const PRUNE_BATCH_SIZE = 5000;
|
|
11
14
|
/**
|
|
12
15
|
* Service for recording and querying row change history.
|
|
13
16
|
* Stores history entries in the `rebase.entity_history` table.
|
|
@@ -21,9 +24,41 @@ export declare class HistoryService {
|
|
|
21
24
|
* through the pool and commit on their own.
|
|
22
25
|
*/
|
|
23
26
|
private readonly inTransaction;
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
/**
|
|
28
|
+
* What new entries are stored as — see `EntityHistoryEntry.format`. `2`,
|
|
29
|
+
* the previous values of the changed fields only, needs the table's
|
|
30
|
+
* `format` column, so it is what `ensureHistoryTableExists` found; a
|
|
31
|
+
* service built without saying stores whole rows, as it always did.
|
|
32
|
+
*/
|
|
33
|
+
private readonly entryFormat;
|
|
34
|
+
/**
|
|
35
|
+
* What the database lacks for history to be recorded, when it lacks
|
|
36
|
+
* something — `the rebase.entity_history table`. Set for a driver opened
|
|
37
|
+
* without provisioning on a database no boot with history has prepared:
|
|
38
|
+
* writes to a `history: true` collection are then refused before they
|
|
39
|
+
* start (see {@link assertRecordable}), rather than made without their
|
|
40
|
+
* audit entries.
|
|
41
|
+
*/
|
|
42
|
+
private readonly unavailable?;
|
|
43
|
+
/**
|
|
44
|
+
* Whether recording an entry also prunes that row's history to
|
|
45
|
+
* {@link retention}. Off for a process that does not know the retention the
|
|
46
|
+
* project's server is configured with — `openRebase` — which would
|
|
47
|
+
* otherwise delete entries the server keeps. What it leaves is pruned by
|
|
48
|
+
* the server: the row's next write, and the hourly sweep.
|
|
49
|
+
*/
|
|
50
|
+
private readonly pruneOnRecord;
|
|
51
|
+
constructor(db: NodePgDatabase, retention?: Partial<HistoryRetentionConfig>, options?: Partial<HistoryTableState> & {
|
|
52
|
+
unavailable?: string;
|
|
53
|
+
pruneOnRecord?: boolean;
|
|
26
54
|
});
|
|
55
|
+
/**
|
|
56
|
+
* Refuse a write to `collection` (a `history: true` collection's slug)
|
|
57
|
+
* when its entry could not be recorded. Called by the driver before the
|
|
58
|
+
* write runs anything — hooks included — so a refused write has no side
|
|
59
|
+
* effects. Reads are never refused.
|
|
60
|
+
*/
|
|
61
|
+
assertRecordable(collection: string): void;
|
|
27
62
|
/**
|
|
28
63
|
* Record a history entry for a row change.
|
|
29
64
|
*
|
|
@@ -68,15 +103,39 @@ export declare class HistoryService {
|
|
|
68
103
|
* Fetch a single history entry by ID.
|
|
69
104
|
*/
|
|
70
105
|
fetchHistoryEntry(historyId: string): Promise<HistoryEntry | null>;
|
|
106
|
+
/**
|
|
107
|
+
* Each entry's `format`. A table without the column holds only entries
|
|
108
|
+
* that store the whole previous row, which is what `1` says.
|
|
109
|
+
*/
|
|
110
|
+
private formatColumn;
|
|
71
111
|
/**
|
|
72
112
|
* Prune history for a single row: enforce maxEntries and TTL.
|
|
73
113
|
*/
|
|
74
114
|
pruneEntity(tableName: string, id: string): Promise<number>;
|
|
75
115
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
116
|
+
* Delete every entry older than `ttlDays`, whichever row it belongs to.
|
|
117
|
+
*
|
|
118
|
+
* The inline prune above only ever visits a row that was just written,
|
|
119
|
+
* so a row nobody writes again — every deleted one — kept its history for
|
|
120
|
+
* good, whatever `ttlDays` said. This is the other half: the backend runs
|
|
121
|
+
* it once an hour, on one instance of the fleet (see
|
|
122
|
+
* `startHistoryRetentionSweep` in `@rebasepro/server`).
|
|
123
|
+
*
|
|
124
|
+
* In batches of {@link PRUNE_BATCH_SIZE}, each its own statement, repeated
|
|
125
|
+
* until one comes back short: a first sweep over a year of backlog is many
|
|
126
|
+
* short deletes, not one that holds millions of row locks and a pool
|
|
127
|
+
* connection for minutes. `SKIP LOCKED`, so two instances sweeping at once
|
|
128
|
+
* (or a sweep meeting an inline prune) split the work instead of waiting
|
|
129
|
+
* on each other. Each batch reads `idx_history_updated_at`, built in the
|
|
130
|
+
* background at boot (`ensureHistoryIndexes`).
|
|
131
|
+
*
|
|
132
|
+
* `signal` ends it after the batch in flight: a shutdown waits for the
|
|
133
|
+
* sweep, and a first sweep over a large backlog is hundreds of batches.
|
|
134
|
+
* What is left goes in the next sweep.
|
|
78
135
|
*/
|
|
79
|
-
pruneExpired(
|
|
136
|
+
pruneExpired(options?: {
|
|
137
|
+
signal?: AbortSignal;
|
|
138
|
+
}): Promise<number>;
|
|
80
139
|
}
|
|
81
140
|
/**
|
|
82
141
|
* Shallow comparison to find top-level keys that changed between two objects.
|
|
@@ -1,13 +1,72 @@
|
|
|
1
1
|
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
2
|
+
import type { DeferredIndexBuild } from "../schema/plan/diff-plan.js";
|
|
3
|
+
import { type BootLockOptions } from "../schema/boot-ddl.js";
|
|
2
4
|
/** How a history entry gets written from inside the write it records. */
|
|
3
5
|
export declare const RECORD_HISTORY_FUNCTION = "rebase.record_history";
|
|
6
|
+
/** What {@link ensureHistoryTableExists} left in place, for `HistoryService`. */
|
|
7
|
+
export interface HistoryTableState {
|
|
8
|
+
/**
|
|
9
|
+
* {@link RECORD_HISTORY_FUNCTION} exists, so an entry inside a write goes
|
|
10
|
+
* on that write's transaction. Without it, entries go through the pool and
|
|
11
|
+
* commit on their own.
|
|
12
|
+
*/
|
|
13
|
+
inTransaction: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* What new entries are stored as. `2` — an update keeps the previous values
|
|
16
|
+
* of its changed fields only (`EntityHistoryEntry.format`) — once the table
|
|
17
|
+
* has its `format` column; `1`, the whole previous row, where the column
|
|
18
|
+
* could not be added this boot.
|
|
19
|
+
*/
|
|
20
|
+
entryFormat: 1 | 2;
|
|
21
|
+
}
|
|
22
|
+
/** Entries by age alone, for the retention sweep (`HistoryService.pruneExpired`). */
|
|
23
|
+
export declare const HISTORY_SWEEP_INDEX = "idx_history_updated_at";
|
|
4
24
|
/**
|
|
5
25
|
* Auto-create the row history table if it doesn't exist.
|
|
6
26
|
* This runs on startup when history is enabled, following the same
|
|
7
27
|
* pattern as `ensureAuthTablesExist`.
|
|
8
28
|
*
|
|
9
|
-
* Resolves
|
|
10
|
-
* be written on the write's own transaction; `false` sends entries through the
|
|
11
|
-
* pool as before, committing on their own.
|
|
29
|
+
* Resolves to what the history service may rely on: see {@link HistoryTableState}.
|
|
12
30
|
*/
|
|
13
|
-
export declare function ensureHistoryTableExists(db: NodePgDatabase): Promise<
|
|
31
|
+
export declare function ensureHistoryTableExists(db: NodePgDatabase, options?: BootLockOptions): Promise<HistoryTableState>;
|
|
32
|
+
/**
|
|
33
|
+
* What an earlier boot left in place, read without changing anything — for a
|
|
34
|
+
* driver opened without provisioning. Entries go on the write's transaction
|
|
35
|
+
* when the function for the table's entry format is there, and the format is
|
|
36
|
+
* `2` when the table has its `format` column. `tableExists` is false on a
|
|
37
|
+
* database no boot with history has provisioned.
|
|
38
|
+
*/
|
|
39
|
+
export declare function readHistoryTableState(db: NodePgDatabase): Promise<HistoryTableState & {
|
|
40
|
+
tableExists: boolean;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Why history cannot be recorded on a database {@link readHistoryTableState}
|
|
44
|
+
* read, or `undefined` when it can. `requireTransaction` also counts a
|
|
45
|
+
* missing {@link RECORD_HISTORY_FUNCTION}: without it an entry would commit on
|
|
46
|
+
* its own instead of with its row.
|
|
47
|
+
*/
|
|
48
|
+
export declare function historyUnavailableReason(state: HistoryTableState & {
|
|
49
|
+
tableExists: boolean;
|
|
50
|
+
}, options: {
|
|
51
|
+
requireTransaction: boolean;
|
|
52
|
+
}): string | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Bring the history table's indexes to what its reads need, and say which one
|
|
55
|
+
* is left to build in the background.
|
|
56
|
+
*
|
|
57
|
+
* - `idx_history_entity` is dropped: `idx_history_time` leads with the same two
|
|
58
|
+
* columns, so it served nothing the other does not, and cost a btree insert
|
|
59
|
+
* per recorded change. A `DROP INDEX` takes the table's `ACCESS EXCLUSIVE`
|
|
60
|
+
* lock for an instant, so it runs under the boot's lock budget — one second
|
|
61
|
+
* per attempt, a few attempts — and a table something holds the whole time
|
|
62
|
+
* keeps the index until the next boot. Only once `idx_history_time` is there
|
|
63
|
+
* and valid, so a per-row lookup never loses its index.
|
|
64
|
+
* - `idx_history_updated_at`, which the retention sweep reads, is returned for
|
|
65
|
+
* `buildDeferredIndexes`: on a table that already holds years of history the
|
|
66
|
+
* build takes seconds to minutes, so it is built `CONCURRENTLY` after the boot,
|
|
67
|
+
* blocking no read or write. Nothing is returned when it is already valid.
|
|
68
|
+
*
|
|
69
|
+
* Never throws: an index that cannot be dropped or read about is logged, and
|
|
70
|
+
* the next boot asks again.
|
|
71
|
+
*/
|
|
72
|
+
export declare function ensureHistoryIndexes(db: NodePgDatabase, options?: BootLockOptions): Promise<DeferredIndexBuild[]>;
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from "./services/BranchService.js";
|
|
|
14
14
|
export * from "./backup/index.js";
|
|
15
15
|
export * from "./PostgresBootstrapper.js";
|
|
16
16
|
export * from "./PostgresAdapter.js";
|
|
17
|
+
export * from "./open-rebase.js";
|
|
17
18
|
/**
|
|
18
19
|
* The app-role provisioning boot performs, for callers that restore a database
|
|
19
20
|
* outside a boot.
|