Skip to content

Trashing a published document that has a pending draft replaces the live content with the draft #19449

Open

Description

@volodymyrshk

Describe the Bug

Trashing a published post that has a pending draft replaces the published content with the draft content and sets _status to draft. Restoring it does not bring the published version back.

I know #15981 made trash start from the latest version so that draft-only documents do not lose data. I am not sure this case was meant to be covered too, so this may be a question more than a bug.

The collection has trash: true and versions.drafts. I use the same request the admin UI sends when you trash a document (PATCH with { deletedAt }, no draft flag):

  1. Create and publish a post titled published-v1.
  2. Save a draft titled draft-v2. The main document still shows published-v1.
  3. Trash the post.
  4. Restore it (deletedAt: null).

After step 3 the main document is draft-v2 with _status: draft. After step 4 it is still draft-v2 / draft. The published content is no longer live. A post without a pending draft is restored correctly as published.

Expected: restoring gives back the document as it was, published-v1 published, with draft-v2 still pending.

Version history still has the published-v1 version, so it can be restored by hand.

Link to the code that reproduces this issue

https://github.com/volodymyrshk/payload-draft-repros

Reproduction Steps

  1. git clone https://github.com/volodymyrshk/payload-draft-repros && cd payload-draft-repros
  2. npm install
  3. npm run trash

It prints the main document and the latest version after each step. The collection is posts with trash: true and versions.drafts, using @payloadcms/db-sqlite. The script uses the Local API only. I have only run it on SQLite.

Which area(s) are affected?

area: core, db: sqlite

Environment Info

Payload: 3.93.0
@payloadcms/db-sqlite: 3.93.0
Node.js: v25.6.1
OS: macOS (Darwin)
Next.js: not used (Local API script)

Activity

  1. added
    area: core
    db: sqlite
    on Nov 9, 2026
  2. muhammad-wasif-code commented on Nov 12, 2026

    @muhammad-wasif-code
    Contributor

    I've opened a PR for this: #19537. Trashing a published document with a pending draft now keeps the published content on the main document, and restoring brings it back, while the pending draft stays the latest draft version. It includes a regression test in test/trash/int.spec.ts. Happy to adjust anything.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugPayload OSSarea: coredb: sqlite

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions