{"record":{"id":"e42887532323d975","repo":"payloadcms/payload","slug":"localization-is-not-enabled-in-payload-config-e42887","errorCode":null,"errorMessage":"Localization is not enabled in payload config","messagePattern":"Localization is not enabled in payload config","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/drizzle/src/postgres/predefinedMigrations/localize-status/index.ts","lineNumber":38,"sourceCode":"  const schemaName = db.schemaName ?? 'public'\n\n  if (!collectionSlug && !globalSlug) {\n    throw new Error('Either collectionSlug or globalSlug must be provided')\n  }\n\n  if (collectionSlug && globalSlug) {\n    throw new Error('Cannot provide both collectionSlug and globalSlug')\n  }\n\n  const entitySlug = collectionSlug || globalSlug\n  // Convert camelCase slugs to snake_case and add version prefix/suffix\n  const versionsTable = collectionSlug\n    ? `_${toSnakeCase(collectionSlug)}_v`\n    : `_${toSnakeCase(globalSlug!)}_v`\n  const localesTable = `${versionsTable}_locales`\n\n  if (!payload.config.localization) {\n    throw new Error('Localization is not enabled in payload config')\n  }\n\n  // Check if versions are enabled on this collection/global\n  let entityConfig\n  if (collectionSlug) {\n    const collection = payload.config.collections.find((c) => c.slug === collectionSlug)\n    if (collection) {\n      entityConfig = collection\n    }\n  } else if (globalSlug) {\n    const global = payload.config.globals.find((g) => g.slug === globalSlug)\n    if (global) {\n      entityConfig = global\n    }\n  }\n\n  if (!entityConfig) {\n    throw new Error(","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/drizzle/src/postgres/predefinedMigrations/localize-status/index.ts#L20-L56","documentation":"Precondition error from `migratePostgresLocalizeStatus`: the migration converts per-document `_status` into per-locale `_status`, which is only meaningful when Payload's `localization` config is enabled. If `payload.config.localization` is undefined, the migration cannot know the locale set and aborts.","triggerScenarios":"Running the localize-status predefined migration against a Payload config that has no `localization` block (or where it was removed/disabled), for an entity that nonetheless has versions enabled.","commonSituations":"Running the migration in a test/CI config without localization; migrating before enabling localization in `payload.config.ts`; environments that intentionally run without localization but pulled in the predefined migration script.","solutions":["Enable localization in `payload.config.ts` (`localization: { locales: [...], defaultLocale: '...' }`) before running this migration.","Skip this migration entirely for environments that do not use localization.","Confirm you actually need per-locale status; if not, do not run `migratePostgresLocalizeStatus`."],"exampleFix":"// payload.config.ts — before: no localization key\n// after:\nexport default buildConfig({\n  localization: { locales: [{ code: 'en' }, { code: 'fr' }], defaultLocale: 'en' },\n  // ...\n})","handlingStrategy":"validation","validationCode":"if (!payload.config.localization) {\n  payload.logger.info('Localization not enabled; skipping localize-status migration.')\n} else {\n  await migratePostgresLocalizeStatus({ collectionSlug, db, payload, sql })\n}","typeGuard":"const isLocalizationEnabled = (p): boolean => Boolean(p?.config?.localization)","tryCatchPattern":"null","preventionTips":["Gate predefined migrations on the config feature they require.","Run migrations in an environment whose config matches production."],"tags":["migrations","localization","config","predefined-migration"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}