npm run build automatically prepares standalone assets via postbuild (.next/static and public are copied into .next/standalone).
If you connect the project to a fresh or different Postgres database, run the Payload migrations before building or starting the standalone server.
Check migration status:
npm run migrate:statusApply all pending migrations:
npm run migrateCreate a new migration after schema/config changes:
npm run migrate:create your-migration-nameNotes:
npm run devcan be more forgiving during development, butnpm run standaloneexpects the Payload tables to exist./adminrequires the Payload auth tables such asusersto exist.- Run migrations against the same database that is configured in
DATABASE_URL.
After the database schema exists, build the app:
npm run buildnpm run standaloneRecommended order for a fresh database:
npm run migrate
npm run build
npm run standaloneExports all import/export-enabled Payload collections as JSON files into Export/.
npm run export-dataNotes:
- The script requires a valid Payload user.
- The script loads environment variables from your Next.js
.envfiles. - Existing JSON files in
export/are overwritten.
Imports all *.json files from export/ into the matching Payload collections.
npm run import-dataOptional: import with a specific Payload user
$env:PAYLOAD_IMPORT_USER_EMAIL="you@example.com"
npm run import-dataNotes:
- The database schema / tables must already exist before running the import.
- Run
npm run migratefirst if the target database is still empty. - The script uses
upsertwithmatchField: "id". - If a document with the same
idalready exists, it is updated. - If no document with that
idexists, it is created. - Existing documents with different IDs remain untouched.
- JSON files without a matching import-enabled collection are skipped.