Database Cleaner Tool?

Does Discourse have a Database Cleaner tool?

This tool would remove any extra configuration data from the database. The tool would remove any added columns, config rows, and tables from the database that are not present in the default installation of Discourse. The tool would leave all the content and sitesettings alone. The primary focus would be to remove all plugin and theme components from the database.

The best solution I can think of is set up a new instance from a backup :slight_smile:

That’s the cleanest you will get it whilst keeping your forum data without a lot of manual effort.

However, I believe backups will include all the tables that existed in the instance you backed up from and that may include any created by plugins, even if you have not installed the plugin on the new instance.

If you want to get your hands dirty, you can use the rake tasks to drop a database and create a new one and run migrations all over, but that will delete all your data.

This is why “install a new environment and restore a backup” is not the best solution. You still have leftovers from old components and plugins hanging in the database.

There should be a last-effort tool that strips out any component and plugin changes to the database and leaves the data and site settings alone. This tool could be run before going to the new install solution.

I suspect that will be challenging to build:

  1. some migrations are irreversible
  2. many migrations are stored within plugins that won’t be there if they are not installed, so there is nothing to reverse.

But try to build it and see if you can overcome those issues.

1 Like

So basically we have no tools what so ever to move only human content, including categories and tags?

You are using the term “migrations”. What do you mean by this term?

I use the term to refer to “migrating” user data and content into a system. This should never change the default database structure.

The only thing that might change a database structure is a plugin. Unless Discourse is allowing other ways for people to alter database structure.

1 Like

They are in the /db/migrations folder of Discourse and each plugin (that uses them)

1 Like