To use Payload with Postgres, install the package @payloadcms/db-postgres. It leverages Drizzle ORM and node-postgres to interact with a Postgres database that you provide.
It automatically manages changes to your database for you in development mode, and exposes a full suite of migration controls for you to leverage in order to keep other database environments in sync with your schema. DDL transformations are automatically generated.
To configure Payload to use Postgres, pass the postgresAdapter to your Payload Config as follows:
For Db-postgres
import { postgresAdapter } from '@payloadcms/db-postgres'
export default buildConfig({
// Configure the Postgres adapter here
db: postgresAdapter({
// Postgres-specific arguments go here.
// `pool` is required.
pool: {
connectionString: process.env.DATABASE_URI,
},
}),
})