Help us learn about your current experience with the documentation. Take the survey.
数据库字典
本文档记录了 GitLab 的数据库架构,以便数据分析师和其他团队可以找到负责特定数据库表的功能类别。
位置
数据库字典元数据文件存储在 gitlab 项目的 db/docs/ 目录下,适用于 main、ci 和 sec 数据库。
对于 embedding 数据库,字典文件存储在 ee/db/embedding/docs/ 下。
对于 geo 数据库,字典文件存储在 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
table_size: small添加表
架构
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
table_name |
String | yes | 数据库表名。 |
classes |
Array(String) | no | 与此表关联的类列表。 |
feature_categories |
Array(String) | yes | 使用此表的功能类别列表。 |
description |
String | no | 关于表中存储的信息及其用途的文本描述。 |
introduced_by_url |
URL | no | 引入此表的合并请求或提交的 URL。 |
milestone |
String | yes | 引入此表的里程碑。 |
gitlab_schema |
String | yes | GitLab 架构名称。 |
notes |
String | no | 用于注释,因为 Psych 无法解析 YAML 注释。 |
table_size |
String | yes | 在 GitLab.com 上当前表大小的分类[^1]。大小包括索引。对于分区表,大小是最大分区的大小。有效选项为 unknown(未知)、small(< 10 GB)、medium(< 50 GB)、large(< 100 GB)、over_limit(> 100 GB)。 |
[^1] 新表通常默认为 small,因为它们不包含数据。此属性每月自动更新。
流程
添加表时,你应该:
- 在适当的目录为此表创建一个新文件:
gitlab_main表:db/docs/gitlab_ci表:db/docs/gitlab_sec表:db/docs/gitlab_shared表:db/docs/gitlab_embedding表:ee/db/embedding/docs/gitlab_geo表:ee/db/geo/docs/
- 将文件命名为
<table_name>.yml,并包含你对该表所知的尽可能多的信息。 - 在创建该表的迁移提交中包含此文件。
删除表
架构
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
table_name |
String | yes | 数据库表名。 |
classes |
Array(String) | no | 与此表关联的类列表。 |
feature_categories |
Array(String) | yes | 使用此表的功能类别列表。 |
description |
String | no | 关于表中存储的信息及其用途的文本描述。 |
introduced_by_url |
URL | no | 引入此表的合并请求或提交的 URL。 |
milestone |
String | no | 引入此表的里程碑。 |
gitlab_schema |
String | yes | GitLab 架构名称。 |
removed_by_url |
String | yes | 删除此表的合并请求或提交的 URL。 |
removed_in_milestone |
String | yes | 删除此表的里程碑。 |
流程
删除表时,你应该:
- 将此表的字典文件移动到
deleted_tables目录:gitlab_main表:db/docs/deleted_tables/gitlab_ci表:db/docs/deleted_tables/gitlab_sec表:db/docs/deleted_tables/gitlab_shared表:db/docs/deleted_tables/gitlab_embedding表:ee/db/embedding/docs/deleted_tables/gitlab_geo表:ee/db/geo/docs/deleted_tables/
- 向字典文件添加字段
removed_by_url和removed_in_milestone。 - 在删除该表的迁移提交中包含此更改。
添加视图
架构
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
table_name |
String | yes | 数据库视图名。 |
classes |
Array(String) | no | 与此视图关联的类列表。 |
feature_categories |
Array(String) | yes | 使用此视图的功能类别列表。 |
description |
String | no | 关于视图中存储的信息及其用途的文本描述。 |
introduced_by_url |
URL | no | 引入此视图的合并请求或提交的 URL。 |
milestone |
String | no | 引入此视图的里程碑。 |
gitlab_schema |
String | yes | GitLab 架构名称。 |
流程
添加新视图时,你应该:
- 在适当的目录为此视图创建一个新文件:
gitlab_main视图:db/docs/views/gitlab_ci视图:db/docs/views/gitlab_sec视图:db/docs/views/gitlab_shared视图:db/docs/views/gitlab_embedding视图:ee/db/embedding/docs/views/gitlab_geo视图:ee/db/geo/docs/views/
- 将文件命名为
<view_name>.yml,并包含你对该视图所知的尽可能多的信息。 - 在创建该视图的迁移提交中包含此文件。
删除视图
架构
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
view_name |
String | yes | 数据库视图名。 |
classes |
Array(String) | no | 与此视图关联的类列表。 |
feature_categories |
Array(String) | yes | 使用此视图的功能类别列表。 |
description |
String | no | 关于视图中存储的信息及其用途的文本描述。 |
introduced_by_url |
URL | no | 引入此视图的合并请求或提交的 URL。 |
milestone |
String | no | 引入此视图的里程碑。 |
gitlab_schema |
String | yes | GitLab 架构名称。 |
removed_by_url |
String | yes | 删除此视图的合并请求或提交的 URL。 |
removed_in_milestone |
String | yes | 删除此视图的里程碑。 |
流程
删除视图时,你应该:
- 将此表的字典文件移动到
deleted_views目录:gitlab_main视图:db/docs/deleted_views/gitlab_ci视图:db/docs/deleted_views/gitlab_sec视图:db/docs/deleted_views/gitlab_shared视图:db/docs/deleted_views/gitlab_embedding视图:ee/db/embedding/docs/deleted_views/gitlab_geo视图:ee/db/geo/docs/deleted_views/
- 向字典文件添加字段
removed_by_url和removed_in_milestone。 - 在删除该视图的迁移提交中包含此更改。