RENAME TABLE graphite TO old_graphite; CREATE TABLE graphite ENGINE = GraphiteMergeTree('graphite_rollup') PARTITION BY toYYYYMM(Date) ORDER BY (Path, Time) SETTINGS index_granularity = 8192 AS SELECT replaceOne(Path, 'mitigator.', 'mitigator.1.') AS Path, Value, Time, Date, Timestamp FROM old_graphite; RENAME TABLE graphite_tagged TO old_graphite_tagged; CREATE TABLE graphite_tagged ENGINE = ReplacingMergeTree(Version) PARTITION BY toYYYYMM(Date) ORDER BY (Tag1, Path, Date) SETTINGS index_granularity = 8192 AS SELECT Date, Tag1, replaceOne(Path, 'mitigator.', 'mitigator.1.') AS Path, Tags, Version FROM old_graphite_tagged; TRUNCATE TABLE graphite_index; DROP TABLE old_graphite; DROP TABLE old_graphite_tagged;