We're Hiring!

Mattermost, Inc.

Is it possible to store new fields / edit database schema via a plugin?

What are all the ways to store data on a plugin? I see most examples using the config file but I was thinking of directly modifying the schema of the user to add custom fields. Is this possible via a plugin & if not, what is the best alternative way to do it?

I also see KVSet, can someone explain how that works? Is it scalable to use it as a way to add fields to the user model, and does the data get deleted on plugin uninstall / server restart - where is it stored?

In theory, from my understanding, as long as the plugin has the proper runtime permissions and can be called from the user interface, it would be theoretically possible to make CREATE queries, etc, from a programmatic level, within a plugin, for MySQL at least.

Now, from a security standpoint, that would be pretty risky, since directly editing the schema would require that the Mattermost database user has additional permissions, which would then make the database and it’s PII contained within it much more vulnerable to exploitation, both from internal and external access. I would suggest thoroughly attempting to break into the plugin before production use, or you could be writing yourself your own backdoor :slight_smile:

1 Like