doc/development/database/database_dictionary.md
This page documents the database schema for GitLab, so data analysts and other groups can locate the feature categories responsible for specific database tables.
Database dictionary metadata files are stored in the gitlab project under db/docs/ for the main, ci, and sec databases.
For the embedding database, the dictionary files are stored under ee/db/embedding/docs/.
For the geo database, the dictionary files are stored under ee/db/geo/docs/.
---
table_name: terraform_states
classes:
- Terraform::State
feature_categories:
- infrastructure_as_code
description: Represents a Terraform state backend
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/26619
milestone: '13.0'
gitlab_schema: gitlab_main_org
sharding_key:
project_id: projects
table_size: small
| Attribute | Type | Required | Description |
|---|---|---|---|
table_name | String | yes | Database table name. |
classes | Array(String) | no | List of classes that are associated to this table. |
feature_categories | Array(String) | yes | List of feature categories using this table. |
description | String | no | Text description of the information stored in the table, and its purpose. |
introduced_by_url | URL | no | URL to the merge request or commit which introduced this table. |
milestone | String | yes | The milestone that introduced this table. |
gitlab_schema | String | yes | GitLab schema name. |
notes | String | no | Use for comments, as Psych cannot parse YAML comments. |
table_size | String | yes | Classification of current table size on GitLab.com. <sup>1</sup> The size includes indexes. For partitioned tables, the size is the size of the largest partition. Valid options are unknown, small (< 10 GB), medium (< 50 GB), large (< 100 GB), over_limit (above 100 GB). |
organization_transfer_support | String | conditional | Required when sharding_key includes organization_id. See Organization transfer support. |
sharding_key | Hash | conditional | Identifies the column used to relate the table to an organization. Only set when the column has a NOT NULL constraint. See Sharding key fields. |
desired_sharding_key | Hash | conditional | Identifies the intended sharding key column when it exists but doesn't have a NOT NULL constraint yet. See Sharding key fields. |
Footnotes:
small by default as they contain no data. This attribute is updated automatically monthly.When adding a table, you should:
gitlab_main table: db/docs/gitlab_ci table: db/docs/gitlab_sec table: db/docs/gitlab_shared table: db/docs/gitlab_embedding table: ee/db/embedding/docs/gitlab_geo table: ee/db/geo/docs/<table_name>.yml, and include as much information as you know about the table.| Attribute | Type | Required | Description |
|---|---|---|---|
table_name | String | yes | Database table name. |
classes | Array(String) | no | List of classes that are associated to this table. |
feature_categories | Array(String) | yes | List of feature categories using this table. |
description | String | no | Text description of the information stored in the table, and its purpose. |
introduced_by_url | URL | no | URL to the merge request or commit which introduced this table. |
milestone | String | no | The milestone that introduced this table. |
gitlab_schema | String | yes | GitLab schema name. |
removed_by_url | String | yes | URL to the merge request or commit which removed this table. |
removed_in_milestone | String | yes | The milestone that removes this table. |
When dropping a table, you should:
deleted_tables directory:
gitlab_main table: db/docs/deleted_tables/gitlab_ci table: db/docs/deleted_tables/gitlab_sec table: db/docs/deleted_tables/gitlab_shared table: db/docs/deleted_tables/gitlab_embedding table: ee/db/embedding/docs/deleted_tables/gitlab_geo table: ee/db/geo/docs/deleted_tables/removed_by_url and removed_in_milestone to the dictionary file.| Attribute | Type | Required | Description |
|---|---|---|---|
table_name | String | yes | Database view name. |
classes | Array(String) | no | List of classes that are associated to this view. |
feature_categories | Array(String) | yes | List of feature categories using this view. |
description | String | no | Text description of the information stored in the view, and its purpose. |
introduced_by_url | URL | no | URL to the merge request or commit which introduced this view. |
milestone | String | no | The milestone that introduced this view. |
gitlab_schema | String | yes | GitLab schema name. |
When adding a new view, you should:
gitlab_main view: db/docs/views/gitlab_ci view: db/docs/views/gitlab_sec view: db/docs/views/gitlab_shared view: db/docs/views/gitlab_embedding view: ee/db/embedding/docs/views/gitlab_geo view: ee/db/geo/docs/views/<view_name>.yml, and include as much information as you know about the view.| Attribute | Type | Required | Description |
|---|---|---|---|
view_name | String | yes | Database view name. |
classes | Array(String) | no | List of classes that are associated to this view. |
feature_categories | Array(String) | yes | List of feature categories using this view. |
description | String | no | Text description of the information stored in the view, and its purpose. |
introduced_by_url | URL | no | URL to the merge request or commit which introduced this view. |
milestone | String | no | The milestone that introduced this view. |
gitlab_schema | String | yes | GitLab schema name. |
removed_by_url | String | yes | URL to the merge request or commit which removed this view. |
removed_in_milestone | String | yes | The milestone that removes this view. |
When dropping a view, you should:
deleted_views directory:
gitlab_main view: db/docs/deleted_views/gitlab_ci view: db/docs/deleted_views/gitlab_sec view: db/docs/deleted_views/gitlab_shared view: db/docs/deleted_views/gitlab_embedding view: ee/db/embedding/docs/deleted_views/gitlab_geo view: ee/db/geo/docs/deleted_views/removed_by_url and removed_in_milestone to the dictionary file.The sharding_key and desired_sharding_key fields track the progress of adding sharding keys to tables. These fields are used for tracking purposes and enable tooling to assist with the sharding process.
sharding_key: Use this field only when the sharding key column has a NOT NULL constraint enforced in the database. This indicates the table is fully sharded and ready for organization isolation.desired_sharding_key: Use this field when the sharding key column exists but doesn't have a NOT NULL constraint yet (for example, during the backfill process). Tooling is available to make backfilling easier when a table has this field set. Once the backfill is complete and the NOT NULL constraint is added, replace desired_sharding_key with sharding_key.For detailed instructions on adding sharding keys to tables, see the sharding guidelines.
Tables sharded by organization_id must be properly handled when transferring users or groups between organizations. The organization_transfer_support field tracks whether this support has been implemented.
The organization_transfer_support field is required when a table's sharding_key includes organization_id.
organization_transfer_support: <status_value>
The value must be one of: supported, todo, or no_work_needed.
supported: The table is properly handled in the organization transfer services.
organization_id.app/services/organizations/transfer/groups_service.rbapp/services/organizations/transfer/users_service.rbee/app/services/ee/organizations/transfer/groups_service.rbtodo: The table needs organization transfer support but doesn't have it yet.
organization_id previously.no_work_needed: The table has been reviewed and does not require any updates during organization transfers.
organization_id is derived from or cascades through other relationships that are already handled.