In order to ensure higher availability, there are two Kong clusters in our company, which are redundantly written by the business layer. We write data to both clusters through our own Dashboard. In this scenario, the id of the Kong entity needs to be generated by our Dashboard.
In the kong 0.13.0 (also 0.14) version, some entities are allowed to set the id (such as plugin) by external, but not partially (such as service/route). This kind of processing is only because the development of the new mode, did not notice this point, or intentionally.
The following is my modification, use support to allow external settings id
kong/db/schema/init.lua function Schema:process_auto_fields(input, context)
function Schema:process_auto_fields(input, context) local output = tablex.deepcopy(input) local now = time() for key, field in self:each_field() do if field.auto then -- this is my modification if field.uuid and context == "insert" then if output[key] == nil then output[key] = utils.uuid() end elseif (key == "created_at" and (context == "insert")) or (key == "updated_at" and (context == "update" or context == "insert")) then output[key] = now end end local field_value = output[key] if field_value ~= nil then local field_type = field.type if field_type == "array" then output[key] = make_array(field_value) elseif field_type == "set" then output[key] = make_set(field_value) end elseif context ~= "update" then handle_missing_field(key, field, output) end end return output end