Skip to content

db-mongodb: Setting prodMigrations causes type error #14374

@jefferyto

Description

@jefferyto

Describe the Bug

Setting prodMigrations for mongooseAdapter causes a type error:

$ npm run build

> db-mongodb-prod-migrations-type-error@1.0.0 build
> cross-env NODE_OPTIONS="--no-deprecation --max-old-space-size=8000" next build

Attention: Next.js now collects completely anonymous telemetry regarding usage.
This information is used to shape Next.js' roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://nextjs.org/telemetry

   ▲ Next.js 15.4.4
   - Environments: .env

   Creating an optimized production build ...
 ✓ Compiled successfully in 101s

./src/app/my-route/route.ts
4:27  Warning: 'request' is defined but never used. Allowed unused args must match /^_/u.  @typescript-eslint/no-unused-vars
5:9  Warning: 'payload' is assigned a value but never used. Allowed unused vars must match /^_/u.  @typescript-eslint/no-unused-vars

./src/migrations/20251028_022444_migration.ts
6:28  Warning: 'payload' is defined but never used. Allowed unused args must match /^_/u.  @typescript-eslint/no-unused-vars
6:37  Warning: 'req' is defined but never used. Allowed unused args must match /^_/u.  @typescript-eslint/no-unused-vars
6:42  Warning: 'session' is defined but never used. Allowed unused args must match /^_/u.  @typescript-eslint/no-unused-vars
10:30  Warning: 'payload' is defined but never used. Allowed unused args must match /^_/u.  @typescript-eslint/no-unused-vars
10:39  Warning: 'req' is defined but never used. Allowed unused args must match /^_/u.  @typescript-eslint/no-unused-vars
10:44  Warning: 'session' is defined but never used. Allowed unused args must match /^_/u.  @typescript-eslint/no-unused-vars

info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/app/api-reference/config/eslint#disabling-rules
Failed to compile.

./src/payload.config.ts:33:5
Type error: Type '{ up: ({ payload, req, session }: MigrateUpArgs) => Promise<void>; down: ({ payload, req, session }: MigrateDownArgs) => Promise<void>; name: string; }[]' is not assignable to type 'Migration[]'.
  Type '{ up: ({ payload, req, session }: MigrateUpArgs) => Promise<void>; down: ({ payload, req, session }: MigrateDownArgs) => Promise<void>; name: string; }' is not assignable to type 'Migration'.
    Type '{ up: ({ payload, req, session }: MigrateUpArgs) => Promise<void>; down: ({ payload, req, session }: MigrateDownArgs) => Promise<void>; name: string; }' is not assignable to type '{ down: (args: unknown) => Promise<void>; up: (args: unknown) => Promise<void>; }'.
      Types of property 'down' are incompatible.
        Type '({ payload, req, session }: MigrateDownArgs) => Promise<void>' is not assignable to type '(args: unknown) => Promise<void>'.
          Types of parameters '__0' and 'args' are incompatible.
            Type 'unknown' is not assignable to type 'MigrateDownArgs'.

  31 |   db: mongooseAdapter({
  32 |     url: process.env.DATABASE_URI || '',
> 33 |     prodMigrations: migrations,
     |     ^
  34 |   }),
  35 |   sharp,
  36 |   plugins: [
Next.js build worker exited with code: 1 and signal: null

Link to the code that reproduces this issue

https://github.com/jefferyto/payload-db-mongodb-prod-migrations-type-error

Reproduction Steps

  1. Add a migration with npm run payload migrate:create
  2. Set prodMigrations to the added migration in payload.config.ts
  3. Do a production build with npm run build

Which area(s) are affected? (Select all that apply)

db: mongodb

Environment Info

Binaries:
  Node: 22.21.0
  npm: 11.6.2
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  payload: 3.61.1
  next: 15.4.4
  @payloadcms/db-mongodb: 3.61.1
  @payloadcms/email-nodemailer: 3.61.1
  @payloadcms/graphql: 3.61.1
  @payloadcms/next/utilities: 3.61.1
  @payloadcms/payload-cloud: 3.61.1
  @payloadcms/richtext-lexical: 3.61.1
  @payloadcms/translations: 3.61.1
  @payloadcms/ui/shared: 3.61.1
  react: 19.1.0
  react-dom: 19.1.0
Operating System:
  Platform: linux
  Arch: x64
  Version: #34-Ubuntu SMP PREEMPT_DYNAMIC Wed Sep 17 09:21:29 UTC 2025
  Available memory (MB): 7225
  Available CPU cores: 4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions