Enable comment and private_comment tables to share unique IDs between them #664

Closed
opened 2026-07-13 13:59:38 +00:00 by nphilipp · 1 comment
Member

Story

As a user of Forgejo,
I want that comments, private or public, are addressed uniquely,
so that I can point others to them directly.

Acceptance Criteria

  • When private comments are created, don’t use ID values assigned by the database, but (temporarily) allocate an entry in the public table, use its ID, and delete the temporary entry.
  • When private comments are inserted, the BeforeInsert() method checks that their ID field is set (≠ 0).
  • The private_comment table in the database is created in a way that the id column won’t be set automatically on insertion (i.e. without autoincr in the XORM tag). To do this, the reflect package is used to rework the real PrivateComment type dynamically just for passing it to db.RegisterModel().

Background

This is about stealing ID values for private comments from the (public) comment table, see the corresponding spike: #652

# Story As a user of Forgejo, I want that comments, private or public, are addressed uniquely, so that I can point others to them directly. # Acceptance Criteria - [x] When private comments are created, don’t use ID values assigned by the database, but (temporarily) allocate an entry in the public table, use its ID, and delete the temporary entry. - [x] When private comments are inserted, the `BeforeInsert()` method checks that their ID field is set (≠ 0). - [x] The `private_comment` table in the database is created in a way that the `id` column won’t be set automatically on insertion (i.e. without `autoincr` in the XORM tag). To do this, the `reflect` package is used to rework the real `PrivateComment` type dynamically just for passing it to `db.RegisterModel()`. # Background This is about stealing ID values for private comments from the (public) comment table, see the corresponding spike: #652
nphilipp added this to the Sprint 25 project 2026-07-13 14:20:58 +00:00
Author
Member
This is implemented in my feature branch: https://codeberg.org/nilsph/forgejo/src/branch/private-issues-backend-comments
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
forge/forge#664
No description provided.