Step 1: don’t. Most of the common objects in Discourse have the ability to store “custom fields”, and typically you’ll do a whole lot better if you use those.
Step 2: no, really, don’t. If per-object custom fields won’t do it for you, there’s also PluginStore that maintains per-plugin data seamlessly.
Step 3: if you absolutely, positively need your own database tables, you can change the schema by creating your own ActiveRecord migrations in db/migrate
in your plugin. They get included by core if they exist.
The caveats to modifying the schema are many, and include, but are not limited to:
- Cleaning up your schema changes if your plugin is uninstalled is an unsolved problem.
- If your schema change conflicts with that of another plugin, or core, you’ve just broken the install of everyone who uses your plugin.
- The combination of the above two points means that you could, at some unknown point in the future, break the install of everyone who ever used your plugin, even if they uninstalled it a long time ago.
- Once you’ve broken things, it will require SQL command line experience from everyone who has ever used your plugin to fix.
Please, just use PluginStore. Think of the kittens.