# Database Cleaner Tool?

**URL:** https://meta.discourse.org/t/database-cleaner-tool/346514
**Category:** Support
**Created:** [January 10, 2025, 2:45pm UTC](https://meta.discourse.org/t/database-cleaner-tool/346514 "2025-01-10T14:45:55Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![LotusJeff](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lotusjeff/32/477888_2.png) [@LotusJeff](https://meta.discourse.org/u/LotusJeff)
#### Post date: [January 10, 2025, 2:45pm UTC](https://meta.discourse.org/t/database-cleaner-tool/346514/1 "2025-01-10T14:45:55Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [January 10, 2025, 2:59pm UTC](https://meta.discourse.org/t/database-cleaner-tool/346514/2 "2025-01-10T14:59:53Z")

</div>

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

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.

---

<div class="post-metadata">

### Author: ![LotusJeff](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lotusjeff/32/477888_2.png) [@LotusJeff](https://meta.discourse.org/u/LotusJeff)
#### Post date: [January 10, 2025, 3:13pm UTC](https://meta.discourse.org/t/database-cleaner-tool/346514/3 "2025-01-10T15:13:44Z")

</div>

> [@merefield](#):
>
> 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.

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.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [January 10, 2025, 3:41pm UTC](https://meta.discourse.org/t/database-cleaner-tool/346514/4 "2025-01-10T15:41:14Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [January 10, 2025, 4:04pm UTC](https://meta.discourse.org/t/database-cleaner-tool/346514/5 "2025-01-10T16:04:03Z")

</div>

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

---

<div class="post-metadata">

### Author: ![LotusJeff](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lotusjeff/32/477888_2.png) [@LotusJeff](https://meta.discourse.org/u/LotusJeff)
#### Post date: [January 10, 2025, 4:04pm UTC](https://meta.discourse.org/t/database-cleaner-tool/346514/6 "2025-01-10T16:04:25Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [January 10, 2025, 4:30pm UTC](https://meta.discourse.org/t/database-cleaner-tool/346514/7 "2025-01-10T16:30:36Z")

</div>

> [@LotusJeff](#):
>
> You are using the term “migrations”. What do you mean by this term?

> **[Active Record Migrations — Ruby on Rails Guides](https://guides.rubyonrails.org/active_record_migrations.html)**
>
> Migrations are a feature of Active Record that allows you to evolve your database schema over time. Rather than write schema modifications in pure SQL, migrations allow you to use a Ruby Domain Specific Language (DSL) to describe changes to your...

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