-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathschema-clickhouse.sql
More file actions
33 lines (31 loc) · 1.01 KB
/
schema-clickhouse.sql
File metadata and controls
33 lines (31 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
-- ClickHouse schema for BBS file catalog.
-- Replaces per-agent MySQL/MyISAM tables (file_catalog_{N}, catalog_dirs_{N})
-- with two unified tables partitioned by agent_id.
--
-- Run by bbs-install and bbs-update-run:
-- clickhouse-client -d bbs --multiquery < schema-clickhouse.sql
CREATE TABLE IF NOT EXISTS file_catalog (
agent_id UInt32,
archive_id UInt32,
path String,
file_name String,
parent_dir String,
file_size UInt64,
status FixedString(1) DEFAULT 'U',
mtime Nullable(DateTime)
) ENGINE = MergeTree()
PARTITION BY agent_id
ORDER BY (agent_id, archive_id, parent_dir, file_name)
SETTINGS index_granularity = 8192;
CREATE TABLE IF NOT EXISTS catalog_dirs (
agent_id UInt32,
archive_id UInt32,
dir_path String,
parent_dir String,
name String,
file_count UInt32,
total_size UInt64
) ENGINE = ReplacingMergeTree()
PARTITION BY agent_id
ORDER BY (agent_id, archive_id, parent_dir, name)
SETTINGS index_granularity = 8192;