feat: preserve child tombstones#120
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1572fb3b9f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| or (deleted_at is not null and deletion_reason is not null and trim(deletion_reason) <> '')), | ||
| unique(thread_id, comment_type, github_id) | ||
| )`, | ||
| columns: "id, thread_id, github_id, comment_type, author_login, author_type, body, is_bot, raw_json, raw_json_blob_id, created_at_gh, updated_at_gh, deleted_at, deletion_reason", |
There was a problem hiding this comment.
Preserve portable comment metadata during the rebuild
When upgrading an existing pruned portable database, comments already contains body_excerpt and body_length (added by ensurePortableExcerptColumns), but this fixed rebuild copies only the canonical columns and then drops the original table. The migration therefore permanently discards the stored original body length and excerpt columns while portable_metadata still advertises comment_excerpts; include these optional portable columns when present, as the thread migration does.
Useful? React with 👍 / 👎.
What Problem This Solves
Gitcrawl child hydration could not distinguish an explicitly deleted comment or pull-request child from an item that happened not to appear in one response. Replacing child snapshots also discarded rows and edit history that a lossless maintainer archive needs to retain.
Why This Change Was Made
Schema v13 applies the existing family tombstone contract to comments, pull-request reviews and review threads, and commit references: stable identities merge by default, absence is neutral, and only a sourced deletion record sets
deleted_atplusdeletion_reason. Editable comments and review threads record revisions, including delete and restore transitions. The migration rebuilds legacy family tables transactionally so upgraded databases receive the same strict tombstone constraints as fresh stores without losing payloads or foreign-key relationships.Portable archives retain the new revision/tombstone tables while applying the existing body truncation and raw-JSON stripping policy to both current and historical review content.
User Impact
Maintainer archives keep child records and edit history across partial responses, explicit deletion, and later restoration. A missing child is no longer interpreted as deleted, and tombstoned rows stay out of active lists, documents, and search until a later live observation restores them.
Evidence
GOWORK=off go test ./...GOWORK=off go vet ./...foreign_key_check.tombstone-proof-finalbinary opened and converged a scratch archive to schema v13. After a live comment sync followed by an empty child response, SQLite still reported one active comment, one baseline comment revision, one retained FTS hit, strict tombstone constraints,quick_check=ok, and no foreign-key violations;doctorreported current schema with no pending migration.