diff --git a/packages/core/installMachine/installSteps/payload/preparePayloadConfig.ts b/packages/core/installMachine/installSteps/payload/preparePayloadConfig.ts index 7edb217..6b4cadc 100644 --- a/packages/core/installMachine/installSteps/payload/preparePayloadConfig.ts +++ b/packages/core/installMachine/installSteps/payload/preparePayloadConfig.ts @@ -11,17 +11,24 @@ export const preparePayloadConfig = async (configPath: PathLike) => { // Replace postgresAdapter with vercelPostgresAdapter const oldImport = `import { postgresAdapter } from '@payloadcms/db-postgres'`; - const newImport = `import { vercelPostgresAdapter as postgresAdapter } from '@payloadcms/db-vercel-postgres'`; + const newImport = `import { postgresAdapter } from '@payloadcms/db-postgres'; import { vercelPostgresAdapter as postgresAdapter } from '@payloadcms/db-vercel-postgres';`; data = data.replace(oldImport, newImport); // Update the db configuration - const dbConfig = `db: postgresAdapter({ - schemaName: "payload", - pool: { - connectionString: process.env.POSTGRES_URL || process.env.DATABASE_URI || "", - }, - })`; + const dbConfig = `db: process.env.POSTGRES_URL + ? vercelPostgresAdapter({ + schemaName: "payload", + pool: { + connectionString: process.env.POSTGRES_URL || "", + }, + }) + : postgresAdapter({ + schemaName: "payload", + pool: { + connectionString: process.env.DATABASE_URI || "", + }, + }),`; data = data.replace( /db:\s*postgresAdapter\(\{[\s\S]*?pool:\s*\{[\s\S]*?connectionString:[\s\S]*?\}[\s\S]*?\}\)/m,