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
@@ -82,8 +82,8 @@ export function buildConsentLogCollection(): CollectionConfig {
|
||||
}
|
||||
|
||||
const purge = createDailyPurge(CONSENT_LOG_SLUG)
|
||||
/** The missing-table line is logged once per process, not on every visitor's click. */
|
||||
let missingTableLogged = false
|
||||
/** The missing-table line is logged once per Payload instance, not on every visitor's click. */
|
||||
const missingTableLogged = new WeakSet<object>()
|
||||
|
||||
export function buildConsentLogEndpoint({ retentionDays = 1095 }: ConsentLogOptions = {}): Endpoint {
|
||||
return {
|
||||
@@ -124,8 +124,8 @@ export function buildConsentLogEndpoint({ retentionDays = 1095 }: ConsentLogOpti
|
||||
return Response.json({ ok: true }, { status: 201 })
|
||||
} catch (err) {
|
||||
if (isMissingTableError(err)) {
|
||||
if (!missingTableLogged) {
|
||||
missingTableLogged = true
|
||||
if (!missingTableLogged.has(req.payload)) {
|
||||
missingTableLogged.add(req.payload)
|
||||
req.payload.logger.error(
|
||||
"[iapl] consent log: the consent-records table does not exist — create and apply a migration (pnpm payload migrate:create consent-log, commit, migrate at container start) or set iapl({ consentLog: false }). Banner choices are not recorded until then; the site works.",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user