commit ed0431f: [Fix] Clickhouse: Fix table schema upload

Vsevolod Stakhov vsevolod at highsecure.ru
Fri Mar 22 13:21:03 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-03-22 13:15:52 +0000
URL: https://github.com/rspamd/rspamd/commit/ed0431f6b6cd24e50fcb8bb9246ad802bbf0aa8c (HEAD -> master)

[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)


More information about the Commits mailing list