From db5f3f3ccdaedd9e8036c3e39fc20650a309a151 Mon Sep 17 00:00:00 2001 From: Patrik Date: Fri, 17 May 2024 13:58:08 -0400 Subject: [PATCH] fix(db-postgres): uuid custom db name (#6409) ## Description Fixes an issue with creating versions when using custom DB names, `uuid`, and drafts. v3 PR [here](https://github.com/payloadcms/payload/pull/6408) - [x] I have read and understand the [CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md) document in this repository. ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## Checklist: - [x] Existing test suite passes locally with my changes --- packages/db-postgres/src/createVersion.ts | 3 +-- test/database/config.ts | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/db-postgres/src/createVersion.ts b/packages/db-postgres/src/createVersion.ts index 03ed91eda8..d030cfcc88 100644 --- a/packages/db-postgres/src/createVersion.ts +++ b/packages/db-postgres/src/createVersion.ts @@ -45,8 +45,7 @@ export async function createVersion( const table = this.tables[tableName] - const relationshipsTable = - this.tables[`_${defaultTableName}${this.versionsSuffix}${this.relationshipsSuffix}`] + const relationshipsTable = this.tables[`${tableName}${this.relationshipsSuffix}`] if (collection.versions.drafts) { await db.execute(sql` diff --git a/test/database/config.ts b/test/database/config.ts index 6ac5a6545b..e9f943e980 100644 --- a/test/database/config.ts +++ b/test/database/config.ts @@ -134,7 +134,9 @@ export default buildConfigWithDefaults({ ], }, ], - versions: true, + versions: { + drafts: true, + }, }, ], globals: [