Empty schema.lua format

I’m working on a custom plugin which, at this point, has no need for configuration options. I’ve been trying to figure out how to create a bare bones schema.lua file based on the examples shown here, but whenever I try to add the plugin to a service, I’m getting a schema violation error:

{
  "message": "primary key violation on key '{id=\"a691beab-1bc4-4dd2-8a4e-5487c1108b6f\"}'",
  "name": "primary key violation",
  "fields": {
    "id": "a691beab-1bc4-4dd2-8a4e-5487c1108b6f"
  },
  "code": 3
}

Here’s what I have so far in my schema.lua file:

local typedefs = require "kong.db.schema.typedefs"

return {
  name = "myplugin",
  fields = {
    {
      consumer = typedefs.no_consumer
    },
  },
}

How does one create an effectively empty schema.lua? Thanks in advance

To add to this, I found this article which describes writing a simple plugin. I modified my schema.lua to effectively mimic the example, making up a config setting which I really don’t need, and I was able to successfully add the plugin to a service. But I don’t understand how as the example doesn’t seem to conform to the structure that Kong documents you need to follow.

Prometheus plugin is a good example (you can ignore the custom_validator):

Thanks, will give it a try!


© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ