You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GitHub Issue及评论ID是否全局唯一?

GitHub Issue & Comment ID Uniqueness: Critical for Your Backup Schema

Hey folks, let's tackle this question head-on since it's make-or-break for your GitHub backup database design.

First, let's clarify the key ID behaviors you need to know:

ID Uniqueness Breakdown

  • Issue id: This is a GitHub-wide unique integer. No two issues (across any repo on the entire platform) will share the same id. Even if an issue is closed, deleted, or moved, that id is never reused.
  • Issue number: This is per-repository sequential (e.g., #1, #2, #3 in your repo). It's what users see and reference, but it's only unique within your specific repo—another repo could have an issue with the same number.
  • Comment id: Just like issue ids, comment ids are globally unique across GitHub. Every comment (on any issue, PR, or discussion) gets a unique id that's never repeated, even if the comment is deleted.

How This Impacts Your Database Schema

Based on this, here's the solid schema approach:

  1. Issues Table:
    • Use the GitHub Issue id as your primary key. Since it's globally unique, you won't run into collisions even if you expand your backup to cover multiple repos later.
    • Keep the number field as a secondary column—this is what users will recognize when looking at backups, so it's useful for display.
  2. Comments Table:
    • Use the Comment id as its primary key.
    • Add a foreign key column issue_id that links directly to the id (not number) in your Issues table. This guarantees you can always reliably map comments to their parent issues, no matter what changes happen in the original repo.

Why This Matters for Your Backup Workflow

Since these IDs are permanent and non-reusable, your backup database will stay consistent over time. You don't have to worry about a new issue or comment overwriting existing records—each entry gets a one-of-a-kind identifier from GitHub itself.

Quick note: When pulling data via the GitHub API or webhooks, prioritize using the id field for your database keys. The number is great for user-facing views, but the id is the stable, unique value you need for backend storage.

内容的提问来源于stack exchange,提问作者nelsonic

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 07:00:30