payloadcms/payload · error · Error

Cannot provide both collectionSlug and globalSlug

Error message

Cannot provide both collectionSlug and globalSlug

What it means

Thrown by migrateSqliteLocalizeStatus when both collectionSlug and globalSlug are supplied. A single migration targets one versioned entity, and a collection and a global are distinct table families, so providing both is ambiguous and rejected.

Source

Thrown at packages/drizzle/src/sqlite/predefinedMigrations/localize-status/index.ts:26

import { migrateMainGlobalStatus } from './migrateMainGlobal.js'

export type LocalizeStatusArgs = {
  collectionSlug?: string
  db: any
  globalSlug?: string
  payload: Payload
  req?: any
}

export async function migrateSqliteLocalizeStatus(args: LocalizeStatusArgs): Promise<void> {
  const { collectionSlug, db, globalSlug, payload, req } = args

  if (!collectionSlug && !globalSlug) {
    throw new Error('Either collectionSlug or globalSlug must be provided')
  }

  if (collectionSlug && globalSlug) {
    throw new Error('Cannot provide both collectionSlug and globalSlug')
  }

  const entitySlug = collectionSlug || globalSlug
  const versionsTable = collectionSlug
    ? `_${toSnakeCase(collectionSlug)}_v`
    : `_${toSnakeCase(globalSlug)}_v`
  const localesTable = `${versionsTable}_locales`

  if (!payload.config.localization) {
    throw new Error('Localization is not enabled in payload config')
  }

  // Check if versions are enabled on this collection/global
  let entityConfig
  if (collectionSlug) {
    entityConfig = payload.config.collections.find((c) => c.slug === collectionSlug)
  } else if (globalSlug) {
    entityConfig = payload.config.globals.find((g) => g.slug === globalSlug)

View on GitHub (pinned to 00c58b35c0)

Solutions

  1. Supply only the slug that matches the entity type you are migrating.
  2. Split the single call into two sequential calls, one per entity.

Example fix

// before
await migrateSqliteLocalizeStatus({ db, payload, collectionSlug: 'posts', globalSlug: 'settings' })
// after
await migrateSqliteLocalizeStatus({ db, payload, collectionSlug: 'posts' })
await migrateSqliteLocalizeStatus({ db, payload, globalSlug: 'settings' })
Defensive patterns

Strategy: validation

Validate before calling

function assertNotBothSlugs(args) {
  if (args.collectionSlug && args.globalSlug) {
    throw new Error('Pass only one of collectionSlug or globalSlug')
  }
}

Prevention

When it happens

Trigger: Calling migrateSqliteLocalizeStatus({ db, payload, collectionSlug: 'posts', globalSlug: 'settings' }).

Common situations: Generic helper that fills both fields 'just in case'; merging two config objects that each set one slug.

Related errors


AI-assisted analysis of payloadcms/payload@00c58b35c0 (2026-08-12). Data as JSON: /api/errors/68bbb1f01b0b2dd0. Report an issue: GitHub.