Adding jsonb columns for custom fields

There is an index on the key column of PluginStoreRow, so if your lookups are always against post_id, you could utilise that.

Setting the key to post_12_<random id>

means you could use a lookup like:

post_id = 12
PluginStoreRow.where("key LIKE ?", "post_#{post_id}_%")

That breaks down as soon as you want to ‘index’ against more than one value, but for a lot of applications it is enough.

6 likes