Guards localized fields, blocks and arrays against silent data loss when saving documents in one locale with the PostgreSQL adapter. It hooks into beforeChange and afterChange, snapshots rows of other locales, and restores them within Payload's own transaction. Requires Payload 3.x, @payloadcms/db-postgres, drizzle-orm and PostgreSQL 14 or newer.
Prevents silent data loss of localized blocks and arrays in Payload CMS with the PostgreSQL adapter.
Installation
npm i payload-locale-snapshot3
Stars
0
Forks
0
Open Issues
2 months ago
Last Updated
59
Weekly Downloads
v0.3.0
npm Version
164.6 KB
Unpacked Size
1
Dependencies
30 since Sep 6
| Date | Stars |
|---|---|
| Dec 5, 2026 | 3 |
| Dec 4, 2026 | 3 |
| Dec 3, 2026 | 3 |
| Dec 2, 2026 | 3 |
| Dec 1, 2026 | 3 |
| Nov 30, 2026 | 3 |
| Nov 29, 2026 | 3 |
| Nov 28, 2026 | 3 |
| Nov 27, 2026 | 3 |
| Nov 26, 2026 | 3 |
| Nov 25, 2026 | 3 |
| Nov 24, 2026 | 3 |
| Nov 23, 2026 | 3 |
| Nov 22, 2026 | 3 |
| Nov 21, 2026 | 3 |
| Nov 20, 2026 | 3 |
| Nov 19, 2026 | 3 |
| Nov 18, 2026 | 3 |
| Nov 17, 2026 | 3 |
| Nov 16, 2026 | 3 |
| Nov 15, 2026 | 3 |
| Nov 14, 2026 | 3 |
| Nov 13, 2026 | 3 |
| Nov 12, 2026 | 3 |
| Nov 11, 2026 | 3 |
| Nov 10, 2026 | 3 |
| Nov 9, 2026 | 3 |
| Nov 8, 2026 | 3 |
| Nov 7, 2026 | 3 |
| Nov 6, 2026 | 3 |
| Nov 5, 2026 | 3 |
| Nov 4, 2026 | 3 |
| Nov 3, 2026 | 3 |
| Nov 2, 2026 | 3 |
| Nov 1, 2026 | 3 |
| Oct 31, 2026 | 3 |
| Oct 30, 2026 | 3 |
| Oct 29, 2026 | 3 |
| Oct 28, 2026 | 3 |
| Oct 27, 2026 | 3 |
| Oct 26, 2026 | 3 |
| Oct 25, 2026 | 3 |
| Oct 24, 2026 | 3 |
| Oct 23, 2026 | 3 |
| Oct 22, 2026 | 3 |
| Oct 21, 2026 | 3 |
| Oct 20, 2026 | 3 |
| Oct 19, 2026 | 3 |
| Oct 18, 2026 | 3 |
| Oct 17, 2026 | 3 |
| Oct 16, 2026 | 3 |
| Oct 15, 2026 | 3 |
| Oct 14, 2026 | 3 |
| Oct 13, 2026 | 3 |
| Oct 12, 2026 | 3 |
| Oct 11, 2026 | 3 |
| Oct 10, 2026 | 3 |
| Oct 9, 2026 | 3 |
| Oct 8, 2026 | 3 |
| Oct 7, 2026 | 3 |
| Oct 6, 2026 | 3 |
| Oct 5, 2026 | 3 |
| Oct 4, 2026 | 3 |
| Oct 3, 2026 | 3 |
| Oct 2, 2026 | 3 |
| Oct 1, 2026 | 3 |
| Sep 30, 2026 | 3 |
| Sep 29, 2026 | 3 |
| Sep 28, 2026 | 3 |
| Sep 27, 2026 | 3 |
| Sep 26, 2026 | 3 |
| Sep 25, 2026 | 3 |
| Sep 24, 2026 | 3 |
| Sep 23, 2026 | 3 |
| Sep 22, 2026 | 3 |
| Sep 21, 2026 | 3 |
| Sep 20, 2026 | 3 |
| Sep 19, 2026 | 3 |
| Sep 18, 2026 | 3 |
| Sep 17, 2026 | 3 |
| Sep 16, 2026 | 3 |
| Sep 15, 2026 | 3 |
| Sep 14, 2026 | 3 |
| Sep 13, 2026 | 3 |
| Sep 12, 2026 | 3 |
| Sep 11, 2026 | 3 |
| Sep 10, 2026 | 3 |
| Sep 9, 2026 | 3 |
| Sep 8, 2026 | 3 |
| Sep 7, 2026 | 3 |
| Sep 6, 2026 | 3 |
26−6 since Sep 6
| Date | Weekly downloads |
|---|---|
| Dec 5, 2026 | 26 |
| Dec 4, 2026 | 17 |
| Dec 3, 2026 | 16 |
| Dec 2, 2026 | 21 |
| Dec 1, 2026 | 23 |
| Nov 30, 2026 | 23 |
| Nov 29, 2026 | 25 |
| Nov 28, 2026 | 30 |
| Nov 27, 2026 | 28 |
| Nov 26, 2026 | 28 |
| Nov 25, 2026 | 24 |
| Nov 24, 2026 | 22 |
| Nov 23, 2026 | 21 |
| Nov 22, 2026 | 17 |
| Nov 21, 2026 | 12 |
| Nov 20, 2026 | 11 |
| Nov 19, 2026 | 16 |
| Nov 18, 2026 | 18 |
| Nov 17, 2026 | 18 |
| Nov 16, 2026 | 24 |
| Nov 15, 2026 | 26 |
| Nov 14, 2026 | 33 |
| Nov 13, 2026 | 47 |
| Nov 12, 2026 | 48 |
| Nov 11, 2026 | 44 |
| Nov 10, 2026 | 48 |
| Nov 9, 2026 | 43 |
| Nov 8, 2026 | 45 |
| Nov 7, 2026 | 52 |
| Nov 6, 2026 | 39 |
| Nov 5, 2026 | 33 |
| Nov 4, 2026 | 33 |
| Nov 3, 2026 | 30 |
| Nov 2, 2026 | 32 |
| Nov 1, 2026 | 32 |
| Oct 31, 2026 | 26 |
| Oct 30, 2026 | 25 |
| Oct 29, 2026 | 24 |
| Oct 28, 2026 | 22 |
| Oct 27, 2026 | 28 |
| Oct 26, 2026 | 26 |
| Oct 25, 2026 | 27 |
| Oct 24, 2026 | 22 |
| Oct 23, 2026 | 19 |
| Oct 22, 2026 | 27 |
| Oct 21, 2026 | 36 |
| Oct 20, 2026 | 35 |
| Oct 19, 2026 | 44 |
| Oct 18, 2026 | 43 |
| Oct 17, 2026 | 52 |
| Oct 16, 2026 | 59 |
| Oct 15, 2026 | 69 |
| Oct 14, 2026 | 79 |
| Oct 13, 2026 | 253 |
| Oct 12, 2026 | 247 |
| Oct 11, 2026 | 246 |
| Oct 10, 2026 | 242 |
| Oct 9, 2026 | 242 |
| Oct 8, 2026 | 235 |
| Oct 7, 2026 | 220 |
| Oct 6, 2026 | 44 |
| Oct 5, 2026 | 44 |
| Oct 4, 2026 | 44 |
| Oct 3, 2026 | 39 |
| Oct 2, 2026 | 39 |
| Oct 1, 2026 | 29 |
| Sep 30, 2026 | 30 |
| Sep 29, 2026 | 28 |
| Sep 28, 2026 | 32 |
| Sep 27, 2026 | 28 |
| Sep 26, 2026 | 29 |
| Sep 25, 2026 | 25 |
| Sep 24, 2026 | 28 |
| Sep 23, 2026 | 26 |
| Sep 22, 2026 | 36 |
| Sep 21, 2026 | 31 |
| Sep 20, 2026 | 34 |
| Sep 19, 2026 | 30 |
| Sep 18, 2026 | 28 |
| Sep 17, 2026 | 25 |
| Sep 16, 2026 | 30 |
| Sep 15, 2026 | 20 |
| Sep 14, 2026 | 19 |
| Sep 13, 2026 | 16 |
| Sep 12, 2026 | 20 |
| Sep 11, 2026 | 22 |
| Sep 10, 2026 | 25 |
| Sep 9, 2026 | 26 |
| Sep 8, 2026 | 28 |
| Sep 7, 2026 | 32 |
| Sep 6, 2026 | 32 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1336060174-root)<a href="https://payloaddirectory.dev/plugins/1336060174-root"><img src="https://payloaddirectory.dev/badge/1336060174-root.svg" alt="Payload Directory"></a>README
A zero-loss database stability plugin for Payload CMS 3.x using the PostgreSQL adapter (@payloadcms/db-postgres). It guarantees zero data loss of localized fields, scalars, blocks, nested arrays, and sub-items across all languages when saving documents in any locale.
When using Payload CMS 3.x with PostgreSQL, collections with localized: true fields (scalars, blocks, or arrays) are vulnerable to silent data loss during routine editorial changes in the admin UI or API.
When saving an update for a document (e.g. in the default English locale), Payload's internal Drizzle adapter deletes child rows without a locale filter:
DELETE FROM "pages_blocks_*" WHERE "_parent_id" = <documentId>;
Depending on your Payload version and operation path, only the active locale is re-inserted — wiping out all other translations.
v2.0 note: Earlier versions of this plugin guarded against this using a separate pool connection inside lifecycle hooks. That caused a PostgreSQL transaction deadlock (infinite "Submitting..." on save). v2 executes entirely inside Payload's own transaction — see How it works.
The plugin hooks into Payload's beforeChange and afterChange lifecycles and runs
entirely on Payload's active transaction connection (the adapter's drizzle session
client). No second database connection is ever opened inside a hook — which is what
made v1 deadlock.
beforeChange:
information_schema) — arbitrary nesting depth, blocks-in-arrays,
arrays-in-blocks, per-block _locales content tables, custom dbName overrides.
Version tables (_x_v*) are excluded automatically. Results are TTL-cached.sql template literals → bind params; universal
::text casting supports serial / varchar / UUID ids).afterChange:
ON CONFLICT ("id") DO NOTHING (idempotent if Payload already preserved them)..locale-snapshot-recovery/) is written for offline replay.restoreFromRecoveryDump() replay.npm install payload-locale-snapshot
# or
pnpm add payload-locale-snapshot
# or
yarn add payload-locale-snapshot
payload 3.x, @payloadcms/db-postgres, and drizzle-orm (installed alongside
@payloadcms/db-postgres automatically).
payload.config.tsimport { buildConfig } from 'payload'
import { localeSnapshot } from 'payload-locale-snapshot'
export default buildConfig({
// ...other configuration
plugins: [
localeSnapshot,
// Or with custom options:
// localeSnapshot({
// collections: ['pages', 'products'],
// globals: ['settings'],
// debug: true,
// restoreFailureMode: 'throw',
// maxDepth: 10,
// schemaCacheTTL: 300_000,
// }),
],
})
| Option | Type | Default | Description |
|---|---|---|---|
collections | string[] | Auto-detected | Collection slugs to guard. If omitted, collections with localized fields (scalars, blocks, arrays) are auto-guarded. |
globals | string[] | Auto-detected | Global slugs to guard. |
debug | boolean | true | Detailed snapshot/restore logging. |
restoreFailureMode | 'throw' | 'warn' | 'throw' | On snapshot/restore failure: abort the save (recommended — silent locale loss is worse than a failed save) or log and continue unprotected. |
failOnError | boolean | — | Deprecated. Legacy mapping: true → 'throw', false → 'warn'. Superseded by restoreFailureMode. |
maxDepth | number | 10 | Maximum FK-graph traversal depth. |
schemaCacheTTL | number | 300000 (5 min) | Schema cache TTL in ms. 0 disables caching. Call resetSchemaCache() after migrations. |
serverless | boolean | — | Deprecated / no-op. Nothing is deferred anymore; restoration commits inside the save transaction in all runtimes. |
lockTimeoutMs | number | — | Deprecated / no-op. Advisory locking was removed in v2 (unnecessary and harmful inside a transaction). |
Upgrading from v1? Behavior change: failures now abort the save by default (
restoreFailureMode: 'throw'). PassfailOnError: falseorrestoreFailureMode: 'warn'to keep v1's fail-open behavior.
resetSchemaCache()Invalidates the schema hierarchy cache (useful after running migrations):
import { resetSchemaCache } from 'payload-locale-snapshot'
resetSchemaCache()
restoreFromRecoveryDump(filePath, pool?)Replays an offline recovery dump directly into PostgreSQL:
import { restoreFromRecoveryDump } from 'payload-locale-snapshot'
await restoreFromRecoveryDump('.locale-snapshot-recovery/recovery-pages-15-1786884000000.json')
restoreSnapshot(pool, snapshot)Programmatic restore of a snapshot object on a standalone pool (used by the recovery replay path; runs its own transaction).
^3.0.0 with @payloadcms/db-postgres>=18.20.0docker run -d --name locale-snapshot-test \
-e POSTGRES_PASSWORD=test -e POSTGRES_USER=test -e POSTGRES_DB=snapshot_test \
-p 55432:5432 postgres:16-alpine
npm run build
node --test --test-concurrency=1 test/*.test.js
The suite mechanically reproduces the v1 deadlock against real PostgreSQL
(test/deadlock.repro.test.js) and verifies end-to-end multi-locale preservation,
version-table exclusion, UUID ids, injection safety, and standalone restore
(test/plugin.behavior.test.js).
See LOCALE_SNAPSHOT_POSTMORTEM_AND_PATCH_GUIDE.md
for the full postmortem and architecture rationale.
payload plugin vanguard
One-click backup and restore for Payload content across database and storage adapters
184v3
payload upstash
Upstash Redis key-value adapter for Payload's built-in KV store
82333/wk7v3 v4
payload typeid
TypeID identifiers for Payload collections, as native IDs or an extra type_id field, with PostgreSQL integrity guards
802.6k/wk0v3
payload kv
Store counters, feeds and expiring data in Redis or KV stores while querying them as normal Payload fields
771.4k/wk0v3 v4
payload surrealdb
SurrealDB database adapter for Payload CMS v3 and v4 using its PostgreSQL-compatible SQL interface
77268/wk3v3 v4
payload plugin backup postgres
Scheduled and on-demand PostgreSQL backups with selective restore, stored in Vercel Blob or S3-compatible storage
72118/wk3v3