How to list Projects and Repositories that have been renamed or moved and their aliases in Bitbucket Data Center
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
This knowledge-base article provides queries for listing projects and repositories that have aliases.
Bitbucket 5.0 added the feature for historical aliasing of projects and repositories:
BSERV-3751 - Getting issue details... STATUS
With this feature, projects and repositories that have been renamed or moved can still be accessed using their original identifiers (project keys for projects and and repository slugs/names for repositories).
The original identifiers are referred to as "aliases".
Solution
Tables
Aliases are stored in the following database tables:
Table | Description |
---|---|
bb_repository_alias | A row is added to this table when a repository is renamed or moved between projects |
bb_project_alias | A row is added to this table when a project key is changed |
Sample queries
Repositories that have been renamed or moved
select r.id as repo_id, p.project_key, r.slug as repo_slug, bra.project_key as alias_project_key, bra.slug as alias_repo_slug
from repository r
inner join project p on p.id=r.project_id
inner join bb_repository_alias bra on bra.repository_id=r.id;
Projects whose keys have been changed
select p.id as project_id, p.project_key, bpa.project_key as alias_project_key
from project p
inner join bb_project_alias bpa on bpa.project_id=p.id;