Skip to content

fix(api): Cleanup next_draft_id in versions state only on latest draft#325

Merged
kpsherva merged 1 commit intoinveniosoftware:masterfrom
sakshamarora1:fix/orphan_new_version
Mar 10, 2026
Merged

fix(api): Cleanup next_draft_id in versions state only on latest draft#325
kpsherva merged 1 commit intoinveniosoftware:masterfrom
sakshamarora1:fix/orphan_new_version

Conversation

@sakshamarora1
Copy link
Contributor

@sakshamarora1 sakshamarora1 commented Mar 6, 2026

fixes: #324

  • We check if the draft being hard deleted is the latest version draft, only in that case we need to remove the foreign key from the versions table
  • This fixes the cleanup_drafts task that runs every hour and deletes soft deleted drafts was setting the next_draft_id to None causing any new version draft to become orphaned.
  • It was also causing the new version creation flow to skip the orphan version to the next version's index resulting in holes in the version counter.

@sakshamarora1 sakshamarora1 force-pushed the fix/orphan_new_version branch from 17eda9d to bd959a3 Compare March 6, 2026 12:26
@sakshamarora1 sakshamarora1 changed the title fix(api): Don't remove next_draft_id in versions state fix(api): Cleanup next_draft_id in versions state only on latest draft Mar 6, 2026
Copy link
Member

@ptamarit ptamarit left a comment

Choose a reason for hiding this comment

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

Tests failing with Python 3.14

@kpsherva
Copy link
Contributor

Tests failing with Python 3.14

this PR fixes it inveniosoftware/invenio-drafts-resources#326

  * We check if the draft being hard deleted is the latest version draft, only in that case we need to remove the foreign key from the versions table
  * This fixes the cleanup_drafts task that runs every hour and deletes soft deleted drafts was setting the next_draft_id to None causing any new version draft to become orphaned.
  * It was also causing the new version creation flow to skip the orphan version to the next version's index resulting in holes in the version counter.
@sakshamarora1 sakshamarora1 force-pushed the fix/orphan_new_version branch from bd959a3 to d52a0ba Compare March 10, 2026 14:36
@kpsherva kpsherva merged commit 6cb339c into inveniosoftware:master Mar 10, 2026
3 checks passed
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.

New version draft becomes orphaned if the previous version draft is cleaned up

4 participants