From ed0431f6b6cd24e50fcb8bb9246ad802bbf0aa8c Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 22 Mar 2019 13:15:52 +0000 Subject: [PATCH] [Fix] Clickhouse: Fix table schema upload --- src/plugins/lua/clickhouse.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua index 6fc611cef..924b629c8 100644 --- a/src/plugins/lua/clickhouse.lua +++ b/src/plugins/lua/clickhouse.lua @@ -115,7 +115,7 @@ CREATE TABLE rspamd ) ENGINE = MergeTree(Date, (TS, From), 8192) ]], [[CREATE TABLE rspamd_version ( Version UInt32) ENGINE = TinyLog]], -[[INSERT INTO rspamd_version (Version) Values (2)]], +[[INSERT INTO rspamd_version (Version) Values (${SCHEMA_VERSION})]], } -- This describes SQL queries to migrate between versions @@ -743,7 +743,11 @@ local function upload_clickhouse_schema(upstream, ev_base, cfg) end rspamd_logger.debugm(N, rspamd_config, 'uploaded clickhouse schema element %s to %s', v, upstream:get_addr():to_string(true)) - end, fun.chain(clickhouse_schema, settings.schema_additions)) + end, + -- Also template schema version + fun.map(function(v) + return lua_util.template(v, {SCHEMA_VERSION = tostring(schema_version)}) + end, fun.chain(clickhouse_schema, settings.schema_additions))) end local function maybe_apply_migrations(upstream, ev_base, cfg, version) -- 2.39.5