Question: Primary key state location #4727

Closed
opened 2025-11-02 06:00:57 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @ghost on GitHub (Jan 26, 2020).

Let's say we have some repositories. Each repository has an ID (1, 2, 3, etc.) If I delete the 3rd repository and create a new repository, it will get the ID 4 instead of 3. It looks like Gitea stores somewhere stores the value, and increments it when a new repository is created, giving the repository the previous value. If I remove the repository the value does not get changed back, which I completely understand why. My question is, where does this value get stored in the database / files?

Originally created by @ghost on GitHub (Jan 26, 2020). Let's say we have some repositories. Each repository has an ID (1, 2, 3, etc.) If I delete the 3rd repository and create a new repository, it will get the ID 4 instead of 3. It looks like Gitea stores somewhere stores the value, and increments it when a new repository is created, giving the repository the previous value. If I remove the repository the value does not get changed back, which I completely understand why. My question is, where does this value get stored in the database / files?
GiteaMirror added the type/question label 2025-11-02 06:00:57 -06:00
Author
Owner

@davidsvantesson commented on GitHub (Jan 26, 2020):

It is a feature of SQL databases. The repo id is stored in the database and uses auto increment:
https://www.w3schools.com/sql/sql_autoincrement.asp

@davidsvantesson commented on GitHub (Jan 26, 2020): It is a feature of SQL databases. The repo id is stored in the database and uses auto increment: https://www.w3schools.com/sql/sql_autoincrement.asp
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#4727