Files
payloadcms__payload/test/dbAdapters.ts
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

315 lines
8.8 KiB
TypeScript
Raw Normal View History

import fs from 'fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
type DbAdapter = {
/** Connection-string env var checked before the default URL. */
envVar?: string
/** TCP host. Presence (with `port`) ⇒ assertDbReachable probes the adapter. */
host?: string
/** Display label for error messages. */
label?: string
/** TCP port. Presence (with `host`) ⇒ assertDbReachable probes the adapter. */
port?: number
/** docker-compose service profile for `pnpm docker:start <profile>`. */
profile?: 'mongodb' | 'mongodb-atlas' | 'postgres'
/** Adapter source written into databaseAdapter.js by codegen. */
source: string
}
const MONGO = {
envVar: 'MONGODB_URL',
host: 'localhost',
port: 27018,
label: 'MongoDB',
profile: 'mongodb',
} as const
const MONGO_ATLAS = {
envVar: 'MONGODB_ATLAS_URL',
host: 'localhost',
port: 27019,
label: 'MongoDB Atlas Local',
profile: 'mongodb-atlas',
} as const
const POSTGRES = {
envVar: 'POSTGRES_URL',
host: 'localhost',
port: 5433,
label: 'PostgreSQL',
profile: 'postgres',
} as const
const POSTGRES_REPLICA = {
envVar: 'POSTGRES_REPLICA_URL',
host: 'localhost',
port: 5434,
} as const
const mongoUrlBlock = (e: { envVar: string; host: string; port: number }) => `
ensureIndexes: true,
url:
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
process.env.${e.envVar} || process.env.DATABASE_URL ||
'mongodb://payload:payload@${e.host}:${e.port}/payload?authSource=admin&directConnection=true&replicaSet=rs0',
`
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
const postgresConnString = (e: { envVar: string; host: string; port: number }) =>
`process.env.${e.envVar} || process.env.DATABASE_URL || 'postgres://payload:payload@${e.host}:${e.port}/payload'`
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
/** Used by codegen below and by assertDbReachable.ts (presence of `port` ⇒ probe). */
export const dbAdapters = {
mongodb: {
...MONGO,
source: `
import { mongooseAdapter } from '@payloadcms/db-mongodb'
export const databaseAdapter = mongooseAdapter({
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
${mongoUrlBlock(MONGO)}
})`,
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
},
test: improve database test setup (#14982) This PR brings over most of the test suite improvements I made [here](https://github.com/payloadcms/enterprise-plugins/pull/249) to our payload monorepo. - Replaces mongodb-memory-server with an actual mongo db using the mongodb-community-server docker image. This unblocks the vitest migration PR (https://github.com/payloadcms/payload/pull/14337). Currently, debugging does not work in that PR - this is due to the global setup script that has to start the mongo memory db. - Just like postgres, all mongodb databases now support vector search. mongodb-atlas-local supports it natively, and for mongodb-community-server, our docker compose script installs `mongot`, which unlocks support for vector search. This means we could add [vector storage/search tests similar to the ones we have for postgres](https://github.com/payloadcms/payload/blob/main/test/database/postgres-vector.int.spec.ts) - Int tests now run against both mongodb adapters: mongodb (mongodb-community-server) and mongodb-atlas (mongodb-atlas-local) - Adds docker scripts for mongodb, mongodb-atlas, and postgres, documented in README.md. Updates default db adapter URLs to automatically pick up databases started by those scripts. This makes it easier for people cloning the repo to get started with consistent databases matching CI - no complicated manual installation steps - Simplified db setup handling locally in CI. In CI, everything is scoped to `.github/actions/start-database/action.yml`. Locally, everything is scoped to `test/helpers/db`. Each database adapter now shares the same username, password and db name - Use consistent db connection string env variables, all ending with _URL - Updates the CONTRIBUTING.md with up-to-date information and adds a new database section. We now recommend everyone to use those docker scripts
2025-12-19 07:07:16 -08:00
// mongodb-atlas uses Docker-based MongoDB Atlas Local (all-in-one with search)
// Start with: pnpm docker:start (or --profile mongodb-atlas for just this service)
// Runs on port 27019 to avoid conflicts with mongodb
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
'mongodb-atlas': {
...MONGO_ATLAS,
source: `
test: improve database test setup (#14982) This PR brings over most of the test suite improvements I made [here](https://github.com/payloadcms/enterprise-plugins/pull/249) to our payload monorepo. - Replaces mongodb-memory-server with an actual mongo db using the mongodb-community-server docker image. This unblocks the vitest migration PR (https://github.com/payloadcms/payload/pull/14337). Currently, debugging does not work in that PR - this is due to the global setup script that has to start the mongo memory db. - Just like postgres, all mongodb databases now support vector search. mongodb-atlas-local supports it natively, and for mongodb-community-server, our docker compose script installs `mongot`, which unlocks support for vector search. This means we could add [vector storage/search tests similar to the ones we have for postgres](https://github.com/payloadcms/payload/blob/main/test/database/postgres-vector.int.spec.ts) - Int tests now run against both mongodb adapters: mongodb (mongodb-community-server) and mongodb-atlas (mongodb-atlas-local) - Adds docker scripts for mongodb, mongodb-atlas, and postgres, documented in README.md. Updates default db adapter URLs to automatically pick up databases started by those scripts. This makes it easier for people cloning the repo to get started with consistent databases matching CI - no complicated manual installation steps - Simplified db setup handling locally in CI. In CI, everything is scoped to `.github/actions/start-database/action.yml`. Locally, everything is scoped to `test/helpers/db`. Each database adapter now shares the same username, password and db name - Use consistent db connection string env variables, all ending with _URL - Updates the CONTRIBUTING.md with up-to-date information and adds a new database section. We now recommend everyone to use those docker scripts
2025-12-19 07:07:16 -08:00
import { mongooseAdapter } from '@payloadcms/db-mongodb'
export const databaseAdapter = mongooseAdapter({
ensureIndexes: true,
url:
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
process.env.${MONGO_ATLAS.envVar} || process.env.DATABASE_URL ||
'mongodb://${MONGO_ATLAS.host}:${MONGO_ATLAS.port}/payload?directConnection=true&replicaSet=mongodb-atlas-local',
test: improve database test setup (#14982) This PR brings over most of the test suite improvements I made [here](https://github.com/payloadcms/enterprise-plugins/pull/249) to our payload monorepo. - Replaces mongodb-memory-server with an actual mongo db using the mongodb-community-server docker image. This unblocks the vitest migration PR (https://github.com/payloadcms/payload/pull/14337). Currently, debugging does not work in that PR - this is due to the global setup script that has to start the mongo memory db. - Just like postgres, all mongodb databases now support vector search. mongodb-atlas-local supports it natively, and for mongodb-community-server, our docker compose script installs `mongot`, which unlocks support for vector search. This means we could add [vector storage/search tests similar to the ones we have for postgres](https://github.com/payloadcms/payload/blob/main/test/database/postgres-vector.int.spec.ts) - Int tests now run against both mongodb adapters: mongodb (mongodb-community-server) and mongodb-atlas (mongodb-atlas-local) - Adds docker scripts for mongodb, mongodb-atlas, and postgres, documented in README.md. Updates default db adapter URLs to automatically pick up databases started by those scripts. This makes it easier for people cloning the repo to get started with consistent databases matching CI - no complicated manual installation steps - Simplified db setup handling locally in CI. In CI, everything is scoped to `.github/actions/start-database/action.yml`. Locally, everything is scoped to `test/helpers/db`. Each database adapter now shares the same username, password and db name - Use consistent db connection string env variables, all ending with _URL - Updates the CONTRIBUTING.md with up-to-date information and adds a new database section. We now recommend everyone to use those docker scripts
2025-12-19 07:07:16 -08:00
})`,
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
},
cosmosdb: {
...MONGO,
source: `
import { mongooseAdapter, compatibilityOptions } from '@payloadcms/db-mongodb'
export const databaseAdapter = mongooseAdapter({
...compatibilityOptions.cosmosdb,
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
${mongoUrlBlock(MONGO)}
})`,
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
},
documentdb: {
...MONGO,
source: `
import { mongooseAdapter, compatibilityOptions } from '@payloadcms/db-mongodb'
export const databaseAdapter = mongooseAdapter({
...compatibilityOptions.documentdb,
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
${mongoUrlBlock(MONGO)}
})`,
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
},
firestore: {
...MONGO,
source: `
import { mongooseAdapter, compatibilityOptions } from '@payloadcms/db-mongodb'
fix(db-mongodb): improve compatibility with Firestore database (#12763) ### What? Adds four more arguments to the `mongooseAdapter`: ```typescript useJoinAggregations?: boolean /* The big one */ useAlternativeDropDatabase?: boolean useBigIntForNumberIDs?: boolean usePipelineInSortLookup?: boolean ``` Also export a new `compatabilityOptions` object from `@payloadcms/db-mongodb` where each key is a mongo-compatible database and the value is the recommended `mongooseAdapter` settings for compatability. ### Why? When using firestore and visiting `/admin/collections/media/payload-folders`, we get: ``` MongoServerError: invalid field(s) in lookup: [let, pipeline], only lookup(from, localField, foreignField, as) is supported ``` Firestore doesn't support the full MongoDB aggregation API used by Payload which gets used when building aggregations for populating join fields. There are several other compatability issues with Firestore: - The invalid `pipeline` property is used in the `$lookup` aggregation in `buildSortParams` - Firestore only supports number IDs of type `Long`, but Mongoose converts custom ID fields of type number to `Double` - Firestore does not support the `dropDatabase` command - Firestore does not support the `createIndex` command (not addressed in this PR) ### How? ```typescript useJoinAggregations?: boolean /* The big one */ ``` When this is `false` we skip the `buildJoinAggregation()` pipeline and resolve the join fields through multiple queries. This can potentially be used with AWS DocumentDB and Azure Cosmos DB to support join fields, but I have not tested with either of these databases. ```typescript useAlternativeDropDatabase?: boolean ``` When `true`, monkey-patch (replace) the `dropDatabase` function so that it calls `collection.deleteMany({})` on every collection instead of sending a single `dropDatabase` command to the database ```typescript useBigIntForNumberIDs?: boolean ``` When `true`, use `mongoose.Schema.Types.BigInt` for custom ID fields of type `number` which converts to a firestore `Long` behind the scenes ```typescript usePipelineInSortLookup?: boolean ``` When `false`, modify the sortAggregation pipeline in `buildSortParams()` so that we don't use the `pipeline` property in the `$lookup` aggregation. Results in slightly worse performance when sorting by relationship properties. ### Limitations This PR does not add support for transactions or creating indexes in firestore. ### Fixes Fixed a bug (and added a test) where you weren't able to sort by multiple properties on a relationship field. ### Future work 1. Firestore supports simple `$lookup` aggregations but other databases might not. Could add a `useSortAggregations` property which can be used to disable aggregations in sorting. --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Sasha <64744993+r1tsuu@users.noreply.github.com>
2025-07-17 01:02:43 +05:45
export const databaseAdapter = mongooseAdapter({
...compatibilityOptions.firestore,
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
${mongoUrlBlock(MONGO)}
fix(db-mongodb): improve compatibility with Firestore database (#12763) ### What? Adds four more arguments to the `mongooseAdapter`: ```typescript useJoinAggregations?: boolean /* The big one */ useAlternativeDropDatabase?: boolean useBigIntForNumberIDs?: boolean usePipelineInSortLookup?: boolean ``` Also export a new `compatabilityOptions` object from `@payloadcms/db-mongodb` where each key is a mongo-compatible database and the value is the recommended `mongooseAdapter` settings for compatability. ### Why? When using firestore and visiting `/admin/collections/media/payload-folders`, we get: ``` MongoServerError: invalid field(s) in lookup: [let, pipeline], only lookup(from, localField, foreignField, as) is supported ``` Firestore doesn't support the full MongoDB aggregation API used by Payload which gets used when building aggregations for populating join fields. There are several other compatability issues with Firestore: - The invalid `pipeline` property is used in the `$lookup` aggregation in `buildSortParams` - Firestore only supports number IDs of type `Long`, but Mongoose converts custom ID fields of type number to `Double` - Firestore does not support the `dropDatabase` command - Firestore does not support the `createIndex` command (not addressed in this PR) ### How? ```typescript useJoinAggregations?: boolean /* The big one */ ``` When this is `false` we skip the `buildJoinAggregation()` pipeline and resolve the join fields through multiple queries. This can potentially be used with AWS DocumentDB and Azure Cosmos DB to support join fields, but I have not tested with either of these databases. ```typescript useAlternativeDropDatabase?: boolean ``` When `true`, monkey-patch (replace) the `dropDatabase` function so that it calls `collection.deleteMany({})` on every collection instead of sending a single `dropDatabase` command to the database ```typescript useBigIntForNumberIDs?: boolean ``` When `true`, use `mongoose.Schema.Types.BigInt` for custom ID fields of type `number` which converts to a firestore `Long` behind the scenes ```typescript usePipelineInSortLookup?: boolean ``` When `false`, modify the sortAggregation pipeline in `buildSortParams()` so that we don't use the `pipeline` property in the `$lookup` aggregation. Results in slightly worse performance when sorting by relationship properties. ### Limitations This PR does not add support for transactions or creating indexes in firestore. ### Fixes Fixed a bug (and added a test) where you weren't able to sort by multiple properties on a relationship field. ### Future work 1. Firestore supports simple `$lookup` aggregations but other databases might not. Could add a `useSortAggregations` property which can be used to disable aggregations in sorting. --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Sasha <64744993+r1tsuu@users.noreply.github.com>
2025-07-17 01:02:43 +05:45
// The following options prevent some tests from failing.
// More work needed to get tests succeeding without these options.
ensureIndexes: true,
disableIndexHints: false,
useAlternativeDropDatabase: false,
})`,
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
},
postgres: {
...POSTGRES,
source: `
import { postgresAdapter } from '@payloadcms/db-postgres'
export const databaseAdapter = postgresAdapter({
pool: {
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
connectionString: ${postgresConnString(POSTGRES)},
},
})`,
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
},
'postgres-custom-schema': {
...POSTGRES,
source: `
import { postgresAdapter } from '@payloadcms/db-postgres'
export const databaseAdapter = postgresAdapter({
pool: {
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
connectionString: ${postgresConnString(POSTGRES)},
},
schemaName: 'custom',
})`,
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
},
'postgres-uuid': {
...POSTGRES,
source: `
import { postgresAdapter } from '@payloadcms/db-postgres'
export const databaseAdapter = postgresAdapter({
idType: 'uuid',
pool: {
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
connectionString: ${postgresConnString(POSTGRES)},
},
})`,
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
},
'postgres-uuidv7': {
...POSTGRES,
source: `
feat(drizzle): add uuidv7 support (#16113) ## Goal Let projects use **UUID v7** (time-ordered UUIDs) for collection IDs via `idType: 'uuidv7'` on Postgres-related adapters (and SQLite wiring), while keeping the same storage shape as v4 UUIDs (native `uuid` on Postgres, text on SQLite). ### What? - Adds a new adapter option `idType: 'uuidv7'` alongside existing `'serial' | 'uuid'` (Postgres) and `'number' | 'uuid'` (SQLite). - Generates IDs in application code with `uuid` package `v7()` (not database-native), so older Postgres versions are still supported. - Reuses the same Drizzle column modeling as UUID v4 where appropriate (`defaultV7` on the raw column, `$defaultFn` / generated schema code). - Adds integration tests behind `PAYLOAD_DATABASE=postgres-uuidv7` and a test adapter preset `postgres-uuidv7`. ### Why? UUID v7 is sortable by creation time and tends to be friendlier for B-tree indexes than random UUID v4, without changing the wire format or Postgres column type. ### How? - Bump `uuid` in `@payloadcms/drizzle` to a version that exports `v7`. - Extend TypeScript `idType` unions and `UUIDRawColumn` with `defaultV7`. - In schema builders (`setColumnID`, `buildDrizzleTable`, `columnToCodeConverter`), set app-side defaults for v7; treat `uuidv7` like `uuid` for relationships and query sanitization via a small `isUUIDType` helper and `getCollectionIdType` mapping to `'text'`. Fixes #11449 --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1213991890379567 --------- Co-authored-by: Sasha Rakhmatulin <sasha@ritsuko.dev>
2026-04-09 15:32:01 +02:00
import { postgresAdapter } from '@payloadcms/db-postgres'
export const databaseAdapter = postgresAdapter({
idType: 'uuidv7',
pool: {
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
connectionString: ${postgresConnString(POSTGRES)},
feat(drizzle): add uuidv7 support (#16113) ## Goal Let projects use **UUID v7** (time-ordered UUIDs) for collection IDs via `idType: 'uuidv7'` on Postgres-related adapters (and SQLite wiring), while keeping the same storage shape as v4 UUIDs (native `uuid` on Postgres, text on SQLite). ### What? - Adds a new adapter option `idType: 'uuidv7'` alongside existing `'serial' | 'uuid'` (Postgres) and `'number' | 'uuid'` (SQLite). - Generates IDs in application code with `uuid` package `v7()` (not database-native), so older Postgres versions are still supported. - Reuses the same Drizzle column modeling as UUID v4 where appropriate (`defaultV7` on the raw column, `$defaultFn` / generated schema code). - Adds integration tests behind `PAYLOAD_DATABASE=postgres-uuidv7` and a test adapter preset `postgres-uuidv7`. ### Why? UUID v7 is sortable by creation time and tends to be friendlier for B-tree indexes than random UUID v4, without changing the wire format or Postgres column type. ### How? - Bump `uuid` in `@payloadcms/drizzle` to a version that exports `v7`. - Extend TypeScript `idType` unions and `UUIDRawColumn` with `defaultV7`. - In schema builders (`setColumnID`, `buildDrizzleTable`, `columnToCodeConverter`), set app-side defaults for v7; treat `uuidv7` like `uuid` for relationships and query sanitization via a small `isUUIDType` helper and `getCollectionIdType` mapping to `'text'`. Fixes #11449 --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1213991890379567 --------- Co-authored-by: Sasha Rakhmatulin <sasha@ritsuko.dev>
2026-04-09 15:32:01 +02:00
},
})`,
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
},
'postgres-read-replica': {
...POSTGRES,
source: `
import { postgresAdapter } from '@payloadcms/db-postgres'
export const databaseAdapter = postgresAdapter({
pool: {
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
connectionString: ${postgresConnString(POSTGRES)},
},
readReplicas: [
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
process.env.${POSTGRES_REPLICA.envVar} || 'postgres://payload:payload@${POSTGRES_REPLICA.host}:${POSTGRES_REPLICA.port}/payload',
],
})`,
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
},
'postgres-read-replicas': {
...POSTGRES,
source: `
import { postgresAdapter } from '@payloadcms/db-postgres'
export const databaseAdapter = postgresAdapter({
pool: {
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
connectionString: ${postgresConnString(POSTGRES)},
},
readReplicas: [
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
process.env.${POSTGRES_REPLICA.envVar} || 'postgres://payload:payload@${POSTGRES_REPLICA.host}:${POSTGRES_REPLICA.port}/payload',
],
})`,
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
},
'content-api': {
envVar: 'CONTENT_API_URL',
source: `
fix: isValidID validation (#15217) ## Scripts ### `script:setup-figma` Sets up the local development environment for testing with content-api: - Clones `enterprise-plugins` repo if not present (sibling directory) - Runs `pnpm install` in enterprise-plugins - Removes `@payloadcms/figma` from `test/package.json` to rely on vitest alias instead ### `test:int:summary` Shows less noisy output for integration tests - reports how many tests failed without detailed error messages. The test suites to run can be easily modified via a hardcoded array. This script is particularly useful when many tests fail (e.g., when starting to develop a new db-adapter). To run it for a specific adapter, prefix with `PAYLOAD_DATABASE` env var. Can be removed once content-api is complete if desired. ## Bug Fixes ### Fixed `isValidID` validation - Now properly checks that value type matches the expected ID type - Rejects numbers when `type === 'text'` (fixes content-api adapter validation) - Only accepts numbers when `type === 'number'` - Added explicit `return false` for invalid cases ## Test Improvements ### Refactored "Schema generation" tests Moved conditional logic inside `it()` blocks instead of wrapping them, preventing "no tests found" errors with new db-adapters. ### Added type casting tests Tests for automatic type coercion in database adapters: - String-to-number conversion in `hasMany` number fields - Date field storage and retrieval as ISO strings - Unix timestamp to ISO string conversion See rationale in the comments of [this PR](https://github.com/payloadcms/enterprise-plugins/pull/300). ### Configured Vitest to run tests from `src/` instead of `dist/` This was very difficult with Jest and eliminates the need to build in watch mode during development. --- **Note:** Current setup is designed for local content-api and db-adapter development. Small modifications will be made in the future to run these tests in CI against a deployed staging content-api URL.
2026-01-16 20:19:25 +00:00
import { contentAPIAdapter } from '@payloadcms/figma'
export const databaseAdapter = contentAPIAdapter({
auth: {
mode: 'devJwt',
},
url: process.env.CONTENT_API_URL || 'http://localhost:8080',
contentSystemId: process.env.CONTENT_SYSTEM_ID || '00000000-0000-4000-8000-000000000001',
})
`,
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
},
'vercel-postgres-read-replica': {
envVar: 'POSTGRES_URL',
source: `
import { vercelPostgresAdapter } from '@payloadcms/db-vercel-postgres'
export const databaseAdapter = vercelPostgresAdapter({
pool: {
test: improve database test setup (#14982) This PR brings over most of the test suite improvements I made [here](https://github.com/payloadcms/enterprise-plugins/pull/249) to our payload monorepo. - Replaces mongodb-memory-server with an actual mongo db using the mongodb-community-server docker image. This unblocks the vitest migration PR (https://github.com/payloadcms/payload/pull/14337). Currently, debugging does not work in that PR - this is due to the global setup script that has to start the mongo memory db. - Just like postgres, all mongodb databases now support vector search. mongodb-atlas-local supports it natively, and for mongodb-community-server, our docker compose script installs `mongot`, which unlocks support for vector search. This means we could add [vector storage/search tests similar to the ones we have for postgres](https://github.com/payloadcms/payload/blob/main/test/database/postgres-vector.int.spec.ts) - Int tests now run against both mongodb adapters: mongodb (mongodb-community-server) and mongodb-atlas (mongodb-atlas-local) - Adds docker scripts for mongodb, mongodb-atlas, and postgres, documented in README.md. Updates default db adapter URLs to automatically pick up databases started by those scripts. This makes it easier for people cloning the repo to get started with consistent databases matching CI - no complicated manual installation steps - Simplified db setup handling locally in CI. In CI, everything is scoped to `.github/actions/start-database/action.yml`. Locally, everything is scoped to `test/helpers/db`. Each database adapter now shares the same username, password and db name - Use consistent db connection string env variables, all ending with _URL - Updates the CONTRIBUTING.md with up-to-date information and adds a new database section. We now recommend everyone to use those docker scripts
2025-12-19 07:07:16 -08:00
connectionString: process.env.POSTGRES_URL || process.env.DATABASE_URL,
},
readReplicas: [process.env.POSTGRES_REPLICA_URL],
})
`,
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
},
sqlite: {
envVar: 'SQLITE_URL',
source: `
import { sqliteAdapter } from '@payloadcms/db-sqlite'
export const databaseAdapter = sqliteAdapter({
client: {
test: improve database test setup (#14982) This PR brings over most of the test suite improvements I made [here](https://github.com/payloadcms/enterprise-plugins/pull/249) to our payload monorepo. - Replaces mongodb-memory-server with an actual mongo db using the mongodb-community-server docker image. This unblocks the vitest migration PR (https://github.com/payloadcms/payload/pull/14337). Currently, debugging does not work in that PR - this is due to the global setup script that has to start the mongo memory db. - Just like postgres, all mongodb databases now support vector search. mongodb-atlas-local supports it natively, and for mongodb-community-server, our docker compose script installs `mongot`, which unlocks support for vector search. This means we could add [vector storage/search tests similar to the ones we have for postgres](https://github.com/payloadcms/payload/blob/main/test/database/postgres-vector.int.spec.ts) - Int tests now run against both mongodb adapters: mongodb (mongodb-community-server) and mongodb-atlas (mongodb-atlas-local) - Adds docker scripts for mongodb, mongodb-atlas, and postgres, documented in README.md. Updates default db adapter URLs to automatically pick up databases started by those scripts. This makes it easier for people cloning the repo to get started with consistent databases matching CI - no complicated manual installation steps - Simplified db setup handling locally in CI. In CI, everything is scoped to `.github/actions/start-database/action.yml`. Locally, everything is scoped to `test/helpers/db`. Each database adapter now shares the same username, password and db name - Use consistent db connection string env variables, all ending with _URL - Updates the CONTRIBUTING.md with up-to-date information and adds a new database section. We now recommend everyone to use those docker scripts
2025-12-19 07:07:16 -08:00
url: process.env.SQLITE_URL || process.env.DATABASE_URL || 'file:./payload.db',
},
autoIncrement: true
})`,
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
},
'sqlite-uuid': {
envVar: 'SQLITE_URL',
source: `
import { sqliteAdapter } from '@payloadcms/db-sqlite'
export const databaseAdapter = sqliteAdapter({
idType: 'uuid',
client: {
test: improve database test setup (#14982) This PR brings over most of the test suite improvements I made [here](https://github.com/payloadcms/enterprise-plugins/pull/249) to our payload monorepo. - Replaces mongodb-memory-server with an actual mongo db using the mongodb-community-server docker image. This unblocks the vitest migration PR (https://github.com/payloadcms/payload/pull/14337). Currently, debugging does not work in that PR - this is due to the global setup script that has to start the mongo memory db. - Just like postgres, all mongodb databases now support vector search. mongodb-atlas-local supports it natively, and for mongodb-community-server, our docker compose script installs `mongot`, which unlocks support for vector search. This means we could add [vector storage/search tests similar to the ones we have for postgres](https://github.com/payloadcms/payload/blob/main/test/database/postgres-vector.int.spec.ts) - Int tests now run against both mongodb adapters: mongodb (mongodb-community-server) and mongodb-atlas (mongodb-atlas-local) - Adds docker scripts for mongodb, mongodb-atlas, and postgres, documented in README.md. Updates default db adapter URLs to automatically pick up databases started by those scripts. This makes it easier for people cloning the repo to get started with consistent databases matching CI - no complicated manual installation steps - Simplified db setup handling locally in CI. In CI, everything is scoped to `.github/actions/start-database/action.yml`. Locally, everything is scoped to `test/helpers/db`. Each database adapter now shares the same username, password and db name - Use consistent db connection string env variables, all ending with _URL - Updates the CONTRIBUTING.md with up-to-date information and adds a new database section. We now recommend everyone to use those docker scripts
2025-12-19 07:07:16 -08:00
url: process.env.SQLITE_URL || process.env.DATABASE_URL || 'file:./payload.db',
}
})`,
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
},
'sqlite-uuidv7': {
envVar: 'SQLITE_URL',
source: `
feat(drizzle): add uuidv7 support (#16113) ## Goal Let projects use **UUID v7** (time-ordered UUIDs) for collection IDs via `idType: 'uuidv7'` on Postgres-related adapters (and SQLite wiring), while keeping the same storage shape as v4 UUIDs (native `uuid` on Postgres, text on SQLite). ### What? - Adds a new adapter option `idType: 'uuidv7'` alongside existing `'serial' | 'uuid'` (Postgres) and `'number' | 'uuid'` (SQLite). - Generates IDs in application code with `uuid` package `v7()` (not database-native), so older Postgres versions are still supported. - Reuses the same Drizzle column modeling as UUID v4 where appropriate (`defaultV7` on the raw column, `$defaultFn` / generated schema code). - Adds integration tests behind `PAYLOAD_DATABASE=postgres-uuidv7` and a test adapter preset `postgres-uuidv7`. ### Why? UUID v7 is sortable by creation time and tends to be friendlier for B-tree indexes than random UUID v4, without changing the wire format or Postgres column type. ### How? - Bump `uuid` in `@payloadcms/drizzle` to a version that exports `v7`. - Extend TypeScript `idType` unions and `UUIDRawColumn` with `defaultV7`. - In schema builders (`setColumnID`, `buildDrizzleTable`, `columnToCodeConverter`), set app-side defaults for v7; treat `uuidv7` like `uuid` for relationships and query sanitization via a small `isUUIDType` helper and `getCollectionIdType` mapping to `'text'`. Fixes #11449 --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1213991890379567 --------- Co-authored-by: Sasha Rakhmatulin <sasha@ritsuko.dev>
2026-04-09 15:32:01 +02:00
import { sqliteAdapter } from '@payloadcms/db-sqlite'
export const databaseAdapter = sqliteAdapter({
idType: 'uuidv7',
client: {
url: process.env.SQLITE_URL || process.env.DATABASE_URL || 'file:./payload.db',
}
})`,
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
},
supabase: {
envVar: 'POSTGRES_URL',
source: `
import { postgresAdapter } from '@payloadcms/db-postgres'
export const databaseAdapter = postgresAdapter({
pool: {
connectionString:
test: improve database test setup (#14982) This PR brings over most of the test suite improvements I made [here](https://github.com/payloadcms/enterprise-plugins/pull/249) to our payload monorepo. - Replaces mongodb-memory-server with an actual mongo db using the mongodb-community-server docker image. This unblocks the vitest migration PR (https://github.com/payloadcms/payload/pull/14337). Currently, debugging does not work in that PR - this is due to the global setup script that has to start the mongo memory db. - Just like postgres, all mongodb databases now support vector search. mongodb-atlas-local supports it natively, and for mongodb-community-server, our docker compose script installs `mongot`, which unlocks support for vector search. This means we could add [vector storage/search tests similar to the ones we have for postgres](https://github.com/payloadcms/payload/blob/main/test/database/postgres-vector.int.spec.ts) - Int tests now run against both mongodb adapters: mongodb (mongodb-community-server) and mongodb-atlas (mongodb-atlas-local) - Adds docker scripts for mongodb, mongodb-atlas, and postgres, documented in README.md. Updates default db adapter URLs to automatically pick up databases started by those scripts. This makes it easier for people cloning the repo to get started with consistent databases matching CI - no complicated manual installation steps - Simplified db setup handling locally in CI. In CI, everything is scoped to `.github/actions/start-database/action.yml`. Locally, everything is scoped to `test/helpers/db`. Each database adapter now shares the same username, password and db name - Use consistent db connection string env variables, all ending with _URL - Updates the CONTRIBUTING.md with up-to-date information and adds a new database section. We now recommend everyone to use those docker scripts
2025-12-19 07:07:16 -08:00
process.env.POSTGRES_URL || process.env.DATABASE_URL || 'postgresql://postgres:postgres@127.0.0.1:54322/postgres',
},
})`,
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
},
d1: {
// d1 uses Cloudflare workerd's `binding` rather than a connection string,
// so there's no env var to override.
source: `
import { sqliteD1Adapter } from '@payloadcms/db-d1-sqlite'
export const databaseAdapter = sqliteD1Adapter({ binding: global.d1 })
`,
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
},
} as const satisfies Record<string, DbAdapter>
export type DatabaseAdapterType = keyof typeof dbAdapters
export const defaultPostgresUrl = `postgres://payload:payload@${POSTGRES.host}:${POSTGRES.port}/payload`
/**
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
* Write the chosen adapter's source to test/databaseAdapter.js.
*/
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
export function generateDatabaseAdapter(dbAdapter: DatabaseAdapterType) {
const adapter = dbAdapters[dbAdapter]
if (!adapter) {
throw new Error(`Unknown database adapter: ${dbAdapter}`)
}
fs.writeFileSync(
path.resolve(dirname, 'databaseAdapter.js'),
`
// DO NOT MODIFY. This file is automatically generated by the test suite.
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
${adapter.source}
`,
)
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
return adapter.source
}
export const getCurrentDatabaseAdapter = (): DatabaseAdapterType => {
const dbAdapter = process.env.PAYLOAD_DATABASE as DatabaseAdapterType | undefined
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
if (dbAdapter && Object.keys(dbAdapters).includes(dbAdapter)) {
return dbAdapter
}
chore: monorepo devcontainer support, refactor db adapter and docker start script (#16396) ## Devcontainers Adds dev container configuration, so contributors can open the repo in VS Code without setting up Node, pnpm, or Docker on their own machine. Works for both "Reopen in Container" (your local clone bind-mounted in) and "Clone Repository in Container Volume" (a fresh clone inside an isolated Docker volume, useful when running multiple parallel sessions against the same repo without them stepping on each other). `test/generateDatabaseAdapter.ts` was renamed to `test/dbAdapters.ts` and is the source of truth for anything db-adapter-related in one place: the source templates the codegen writes out, and the host/port/env-var defaults per adapter, which the new `assertDbReachable.ts` function uses to probe services. This should enable running multiple agents conflict-free ## DB Connection probe + docker:start script improvements `assertDbReachable` is now run within `pnpm dev`. If the db connection fails, you now get immediate feedback through a helpful error, instead of having to wait for Next.js to compile and then be thrown off by a cryptic db seed error: <img width="852" height="488" alt="screenshot 2026-04-26 at 15 26 12@2x" src="https://github.com/user-attachments/assets/aecfee0a-20eb-4d25-9215-256f8c8f5f8a" /> `pnpm docker:start` is now an interactive picker. You can still pass profile names as args (`pnpm docker:start postgres mongodb`) to skip the prompt: <img width="898" height="348" alt="screenshot 2026-04-26 at 15 28 04@2x" src="https://github.com/user-attachments/assets/7d4b8f3d-89a5-46b7-b3ca-887a793246b1" /> These changes encourages contributors not to start every single service we have available (uses around 4gb of ram), and only start the database service that you're using => much less memory usage. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1214135483864575
2026-04-28 15:19:58 -07:00
// Default to mongodb, as our e2e tests currently do
// not pass on sqlite/postgres
return 'mongodb'
}