# Adding jsonb columns for custom fields

**URL:** <https://meta.discourse.org/t/adding-jsonb-columns-for-custom-fields/93418>\
**Category:** Development\
**Created:** [7월 29, 2018, 6:55오후 UTC](https://meta.discourse.org/t/adding-jsonb-columns-for-custom-fields/93418 "2018-07-29T18:55:48Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![LeoMcA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leomca/32/87233_2.png) [@LeoMcA](https://meta.discourse.org/u/LeoMcA)\
**Post date:** [8월 16, 2018, 1:20오후 UTC](https://meta.discourse.org/t/adding-jsonb-columns-for-custom-fields/93418/14 "2018-08-16T13:20:08Z")

</div>

That’s how I ended up using it in [`discourse-mozilla-iam`](https://github.com/mozilla/discourse-mozilla-iam), PluginStore for storing a couple of global variables which we need to persist across restarts. Full blown models & tables for everything else.

> [@sam](#):
>
> The big risk around “adding extra tables” is that 2 plugins may fight for 1, which is why I suggested a central registry in core.

I got around this by setting up an engine in my plugin, and placing the model under that namespace. If any other plugin decides to touch a `mozilla_iam_group_mappings` table (or `MozillaIAM::GroupMappings` model), I would be 😲

> [@sam](#):
>
> Only caveat is we need to run them on the test database (which we should fix so it is done by default)

That would be 👌, I should’ve thought to report it when implementing this slight monstrosity:

> <https://github.com/mozilla/discourse-mozilla-iam/blob/master/spec/iam_helper.rb#L20-L21>

---

_[View the full topic](https://meta.discourse.org/t/adding-jsonb-columns-for-custom-fields/93418)._
