Keep an article's publish date across a draft round-trip - #157
Merged
Conversation
Saving as Draft cleared pub_date outright, so the original publish date was gone for good and the next publish stamped today's. That is how the "Opposites" article lost its 2026-07-24 date during an editing session: it is the only row in the database where pub_date no longer matches creation_date, and its new date is the exact second of the PATCH that republished it. Draft now parks the live date in a new last_pub_date column, and publishing without an explicit date reuses the article's own date -- current first, then the parked one -- so only something genuinely never published gets stamped with now. The column is added idempotently in EnsureArticlesSchema, matching how scheduled_pub_date and archived_at were introduced; there is no migration step. Also pins checked sections and subsections to the top of the editor's section list and keeps them visible through a search, the same way the authors list already pins the byline -- unchecking something you can no longer see is how a section assignment silently gets dropped. Adds integration tests (CMS_TEST_DSN) covering the publish-date paths and the scheduled status filter, including its combination with the title search and the fact that it stays invisible to anonymous callers. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Rui Zhao's "Opposites" article lost its publish date during an editing session on Aug 2. The evidence from the live database is unambiguous:
Of 10,001 published articles, 10,000 have
pub_date == creation_dateand exactly one does not. Its new date is the exact second of aPATCH /v1/articles/oppositesin the activity log.A normal save of a live article was already safe —
articlePatchDateColumnsleavespub_datealone — and there is now an integration test proving it. The hole was the draft round-trip: saving as Draft setpub_date = NULLirrecoverably, so the next publish invented today's date.What changed
last_pub_date(new column, added idempotently inEnsureArticlesSchemaalongsidescheduled_pub_dateandarchived_at— no migration step). Going to draft parks the live date there; publishing without an explicit date reuses the article's own date, current first then parked, and only falls back tonowfor something genuinely never published.CMS_TEST_DSN, skipped without it) for the publish-date paths and for the scheduled status filter: on its own, combined with the title search, and confirming it stays invisible to anonymous callers.Verification
go test ./...,tsc --noEmit,npm run lint(one pre-existing warning),npm run build. Integration tests run against a local MariaDB:Not included
The already-damaged row still needs a one-time fix on Delta; this PR does not touch production data:
Separately worth considering: the editor never displays the publish date of a published article (the date field only appears in Schedule mode), so an editor flipping to Draft and back has no way to see the date change underneath them.
🤖 Generated with Claude Code