Skip to content
代码片段 群组 项目
未验证 提交 b90b67db 编辑于 作者: Felipe Cardozo's avatar Felipe Cardozo 提交者: GitLab
浏览文件

Merge branch 'fa-create_group_namespaces_traversal_paths_table' into 'master'

Create ClickHouse table to store namespace traversal paths

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/182164



Merged-by: default avatarFelipe Cardozo <fcardozo@gitlab.com>
Approved-by: default avatarAdam Hegyi <ahegyi@gitlab.com>
Approved-by: default avatarMax Woolf <mwoolf@gitlab.com>
Co-authored-by: default avatarFelipe Artur <felipefac@gmail.com>
No related branches found
No related tags found
2 合并请求!3031Merge per-main-jh to main-jh by luzhiyuan,!3030Merge per-main-jh to main-jh
# frozen_string_literal: true
class CreateNamespaceTraversalPaths < ClickHouse::Migration
def up
execute <<-SQL
CREATE TABLE namespace_traversal_paths (
id Int64 DEFAULT 0,
traversal_path String DEFAULT '0/',
version DateTime64(6, 'UTC') DEFAULT NOW(),
deleted Boolean DEFAULT false
)
ENGINE=ReplacingMergeTree(version, deleted)
PRIMARY KEY id
SETTINGS index_granularity = 512; -- lower granularity so id lookups use less I/O
SQL
end
def down
execute <<-SQL
DROP TABLE IF EXISTS namespace_traversal_paths
SQL
end
end
# frozen_string_literal: true
class CreateNamespaceTraversalPathsMv < ClickHouse::Migration
def up
execute <<-SQL
CREATE MATERIALIZED VIEW namespace_traversal_paths_mv
TO namespace_traversal_paths
AS
SELECT
id,
if(length(traversal_ids) = 0,
toString(ifNull(organization_id, 0)) || '/',
toString(ifNull(organization_id, 0)) || '/' || arrayStringConcat(traversal_ids, '/') || '/') as traversal_path,
_siphon_replicated_at AS version,
_siphon_deleted AS deleted
FROM siphon_namespaces;
SQL
end
def down
execute <<-SQL
DROP VIEW IF EXISTS namespace_traversal_paths_mv
SQL
end
end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册