Consent log: missing-table line once per Payload instance; SQL upgrade proof on Postgres and SQLite
test/consentLogUpgrade.test.ts: a site without the log (migrations applied) upgraded to 1.17.0 — without a migration the site works and a consent write answers 503 with one log line; migrate:create adds only consent_records (and the lock-relation column) and writes succeed. SQLite always; Postgres with IAPL_TEST_PG_URL. Docs say exactly what the migration creates. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f5c53e4523
commit
c6a276823c
+2
-1
@@ -202,7 +202,8 @@ once there are more than 20.
|
||||
|
||||
### Requires project changes
|
||||
- **Postgres / SQLite, consent log (first, before the deploy):** the consent log (`consent-records`) is now on by
|
||||
default. A project that did not set `consentLog` before gets a **new table**: run `pnpm payload migrate:create
|
||||
default. A project that did not set `consentLog` before gets a **new table** (`consent_records`, plus a
|
||||
`consent_records_id` column on Payload's `payload_locked_documents_rels`; nothing dropped): run `pnpm payload migrate:create
|
||||
consent-log`, commit the migration and have it applied when the new container starts (`prodMigrations`, or the start
|
||||
command `pnpm payload migrate && pnpm start`) — **in the same deploy**. Or set `iapl({ consentLog: false })`. Without
|
||||
either nothing breaks: the page and the banner work, `POST /api/ipal/consent` answers `503`, the server logs once
|
||||
|
||||
+6
-4
@@ -579,7 +579,7 @@ to add the hook to a config. Nothing to migrate.
|
||||
| Endpoint | `POST /api/ipal/consent`, public (no login) |
|
||||
| Default | on (since 1.17.0); `consentLog: false` = no collection, no endpoint, `shell.consentLogEndpoint` null |
|
||||
| Body | `{ id: string (hex 16–64), version: int ≥ 1, state: { necessary, functional, analytics, marketing: boolean }, gpc?: boolean }` (`gpc` is accepted and not stored) |
|
||||
| Responses | `201 { ok: true }`, `400` (bad JSON/validation), `429` (limit 20 requests/min per IP, scope `consent`), `503` (the table does not exist: one log line per process), `500` |
|
||||
| Responses | `201 { ok: true }`, `400` (bad JSON/validation), `429` (limit 20 requests/min per IP, scope `consent`), `503` (the table does not exist: one log line per server start), `500` |
|
||||
| Cleanup | on a write, at most once per 24 h per process: one `db.deleteMany` for records older than `retentionDays`, **in the background** (the consent write does not wait; an error is logged and the cleanup is retried on the next write) |
|
||||
|
||||
The provider sends a record after every decision (`fetch` with `keepalive`, errors ignored —
|
||||
@@ -588,9 +588,11 @@ from `@intecion/ipal-kit`; `CONSENT_LOG_PATH` is the endpoint's path under the A
|
||||
|
||||
### Postgres / SQLite: the consent log is a table
|
||||
|
||||
On MongoDB the collection appears by itself. On a SQL database `consent-records` is a table (`consent_records`
|
||||
plus `consent_records_choices`… as Payload names them), so the deploy that brings 1.17.0 to a project that never had
|
||||
`consentLog` on must create it — **in the same deploy**, before the new version serves requests:
|
||||
On MongoDB the collection appears by itself. On a SQL database `consent-records` is a table, so the deploy that
|
||||
brings 1.17.0 to a project that never had `consentLog` on must create it — **in the same deploy**, before the new
|
||||
version serves requests. The migration Payload generates (checked on Postgres 16 and SQLite) creates one table,
|
||||
`consent_records` (the choices are its columns, three indexes), and adds one column, `consent_records_id`, with its
|
||||
index and foreign key to Payload's own `payload_locked_documents_rels`; it drops nothing:
|
||||
|
||||
```bash
|
||||
pnpm payload migrate:create consent-log # commit the file in src/migrations/
|
||||
|
||||
Reference in New Issue
Block a user