Skip to content

Instantly share code, notes, and snippets.

@ochaton
Created May 17, 2023 22:22
Show Gist options
  • Save ochaton/18220d9e7e98608fd0be0fb6fc373884 to your computer and use it in GitHub Desktop.
Save ochaton/18220d9e7e98608fd0be0fb6fc373884 to your computer and use it in GitHub Desktop.
Trigger for upgrade from 1.10.x -> 2.10.x (disables hints)
local tt_version = {}
do
local maj,min,mic,bld = _TARANTOOL:match("(%d+)%.(%d+)%.(%d+)-(%d+)")
if not maj then
maj,min,mic,bld = _TARANTOOL:match("(%d+)%.(%d+)%.(%d+)-([%w%d]+%-%d+)")
end
if not maj then
maj,min,mic,bld = _TARANTOOL:match("(%d+)%.(%d+)%.(%d+)-([%w%d]+)")
end
assert(maj,"Failed to parse version ".._TARANTOOL)
tt_version.maj = tonumber(maj)
tt_version.min = tonumber(min)
tt_version.mic = tonumber(mic)
tt_version.bld = bld
end
local function tt_has_hints()
if tt_version.maj < 2
or tt_version.maj == 2 and tt_version.min < 6
or tt_version.maj == 2 and tt_version.min == 6 and tt_version.mic < 1
then
return false
end
return true
end
if tt_has_hints() then
box.ctl.on_schema_init(function()
local _index = assert(box.space._index)
_index:before_replace(function(old, new, sp, op)
if not new then return end
if new[1] < 512 then return end
local ind = new:totable()
local opts = ind[5] or {}
ind[5] = opts
if opts.hint ~= nil then return end
opts.hint = false
ind = box.tuple.new(ind)
print("apply index trigger ", new, "=>", ind)
return box.tuple.new(ind)
end)
end)
end
box.cfg{}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment