store: ids are not reused after a delete !539

merged merged by cmc on 2026-09-29 15:59 UTC · krz/gitbay:id-reuse-306 into main

Discussion

cmc

Users, orgs, repos, ssh_keys, api_tokens, webhook_deliveries and push_queue get AUTOINCREMENT ids (migration rebuilding the tables with every column, index, trigger and FK kept; sequences seeded above any id still named elsewhere). Build ids come from a stored high-water mark. Deleting a user or org removes its repository grants and pending profile-about row; deleting a repository removes the deploy keys scoped to it and closes their connections. A second migration removes existing orphans (on gitbay.org: 2 grants, 1 deploy key) and logs the counts. Trial-migrated on a copy of the production database: FK and integrity checks clean, schema identical, secrets open. Known-Gaps/Controls/CHANGELOG.

Closes #306