Database Dictionary
This page documents the database schema for GitLab, so data analysts and other groups can locate the feature categories responsible for specific database tables.
Location
Database dictionary metadata files are stored in the gitlab project under db/docs/ for the main and ci 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/.
Example dictionary file
---
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
Adding tables
Schema
| 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. |
Process
When adding a table, you should:
- Create a new file for this table in the appropriate directory:
-
gitlab_maintable:db/docs/ -
gitlab_citable:db/docs/ -
gitlab_sharedtable:db/docs/ -
gitlab_embeddingtable:ee/db/embedding/docs/ -
gitlab_geotable:ee/db/geo/docs/
-
- Name the file
<table_name>.yml, and include as much information as you know about the table. - Include this file in the commit with the migration that creates the table.
Dropping tables
Schema
| 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. |
Process
When dropping a table, you should:
- Move the dictionary file for this table to the
deleted_tablesdirectory:-
gitlab_maintable:db/docs/deleted_tables/ -
gitlab_citable:db/docs/deleted_tables/ -
gitlab_sharedtable:db/docs/deleted_tables/ -
gitlab_embeddingtable:ee/db/embedding/docs/deleted_tables/ -
gitlab_geotable:ee/db/geo/docs/deleted_tables/
-
- Add the fields
removed_by_urlandremoved_in_milestoneto the dictionary file. - Include this change in the commit with the migration that drops the table.
Adding views
Schema
| 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. |
Process
When adding a new view, you should:
- Create a new file for this view in the appropriate directory:
-
gitlab_mainview:db/docs/views/ -
gitlab_ciview:db/docs/views/ -
gitlab_sharedview:db/docs/views/ -
gitlab_embeddingview:ee/db/embedding/docs/views/ -
gitlab_geoview:ee/db/geo/docs/views/
-
- Name the file
<view_name>.yml, and include as much information as you know about the view. - Include this file in the commit with the migration that creates the view.
Dropping views
Schema
| 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. |
Process
When dropping a view, you should:
- Move the dictionary file for this table to the
deleted_viewsdirectory:-
gitlab_mainview:db/docs/deleted_views/ -
gitlab_ciview:db/docs/deleted_views/ -
gitlab_sharedview:db/docs/deleted_views/ -
gitlab_embeddingview:ee/db/embedding/docs/deleted_views/ -
gitlab_geoview:ee/db/geo/docs/deleted_views/
-
- Add the fields
removed_by_urlandremoved_in_milestoneto the dictionary file. - Include this change in the commit with the migration that drops the view.