Is there an automatic way of running the database migration for a custom plugin if it has not already been run? Instead of manually running a DB migration in a fresh Discourse installation?
AI-generated summary
The discussion revolves around running database migrations for custom plugins in Discourse. bstgmr02 asked if there’s an automatic way to run migrations for a custom plugin in a fresh installation. merefield clarified that plugins don’t run migrations themselves, but rather include them for the host app to manage. In a development environment, migrations are run from the console.
Regarding production environments, RGJ explained that migrations are automatically handled during a (re)build, eliminating the need for manual console intervention.
How are you running Discourse?
This should be covered if you’re using our docker installation.
Running the Discourse development environment
You don’t run migrations from within a plugin.
In a Dev environment you perform them from the console.
Why? Because when you deploy a plugin the migrations are taken care of by the host app.
It’s out of scope of what a plugin should do.
(FYI that’s not to say you don’t include migrations within the plugin if you are e.g. modifying the database but the plugin is not going to perform the migrations)
That’s correct, I am using the console to run the migrations in the development environment. My question is that is this the way forward and do I also have to run these manually in the console for a production docker environment?
That would be done automatically as part of a (re)build.