Skip to content

fix(db-postgres): add ON DELETE CASCADE to foreign key constraint of select hasMany relationship#6735

Merged
DanRibbens merged 2 commits into
payloadcms:mainfrom
ikenox:fix/add-delete-cascade-to-select-hasmany-relationship-fk
Jun 19, 2024
Merged

fix(db-postgres): add ON DELETE CASCADE to foreign key constraint of select hasMany relationship#6735
DanRibbens merged 2 commits into
payloadcms:mainfrom
ikenox:fix/add-delete-cascade-to-select-hasmany-relationship-fk

Conversation

@ikenox

@ikenox ikenox commented Jun 12, 2024

Copy link
Copy Markdown

Description

This PR fixes #6485.

  • I have read and understand the CONTRIBUTING.md document in this repository.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have added tests that prove my fix is effective or that my feature works
  • Existing test suite passes locally with my changes

@ikenox

ikenox commented Jun 18, 2024

Copy link
Copy Markdown
Author

Hi @DanRibbens ,
This bug seems critical and easy to fix. Cloud you review this PR?
I know payload team is working hard for v3, thanks.

@DanRibbens DanRibbens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@DanRibbens

Copy link
Copy Markdown
Contributor

Thank you for the nudge on this @ikenox. Once the tests pass we'll get merged.

@ikenox

ikenox commented Jun 19, 2024

Copy link
Copy Markdown
Author

@DanRibbens
Thank you for your immediate response!

The failing test says the following.

  MongoServerError: WriteConflict error: this operation conflicted with another operation. Please retry your operation or multi-document transaction.

        at Connection.onMessage (/home/runner/work/payload/payload/node_modules/.pnpm/mongodb@4.17.1/node_modules/mongodb/src/cmap/connection.ts:449:20)
        at MessageStream.<anonymous> (/home/runner/work/payload/payload/node_modules/.pnpm/mongodb@4.17.1/node_modules/mongodb/src/cmap/connection.ts:241:56)
        at processIncomingData (/home/runner/work/payload/payload/node_modules/.pnpm/mongodb@4.17.1/node_modules/mongodb/src/cmap/message_stream.ts:188:12)
        at MessageStream._write (/home/runner/work/payload/payload/node_modules/.pnpm/mongodb@4.17.1/node_modules/mongodb/src/cmap/message_stream.ts:69:5)

This mongo-db error seems not to be related to the change of this pull request.
The same error often occurs on main branch (e.g. this commit), so this maybe a flaky test.

@DanRibbens DanRibbens merged commit 9ecc6c8 into payloadcms:main Jun 19, 2024
@DanRibbens

Copy link
Copy Markdown
Contributor

This has already been done in beta, no additional PR needed.

Thanks for the contribution @ikenox!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to delete record from admin in postgres if collection has array field type

2 participants