From: Vsevolod Stakhov Date: Fri, 22 Mar 2019 13:15:52 +0000 (+0000) Subject: [Fix] Clickhouse: Fix table schema upload X-Git-Tag: 1.9.1~61 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ed0431f6b6cd24e50fcb8bb9246ad802bbf0aa8c;p=rspamd.git [Fix] Clickhouse: Fix table schema upload --- 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)