הסרת פלאגין ב-multisite

סיכום מבוסס בינה מלאכותית

In a multisite Discourse installation, uninstalling a plugin that modifies the database (like the chat plugin, which adds a chat_enabled column to user_options) can leave behind schema inconsistencies. When a new forum is later added to the multisite, the multisite:seed_fu task may fail due to missing columns, as ActiveRecord model caching assumes uniform schema across all sites. RGJ flags this as a potential bug and tags sam for insight. jimkleiber confirms encountering the same issue. sam acknowledges the problem as a “nightmare” and advises manual cleanup, emphasizing that schema parity across all multisite forums is critical to avoid such errors.

This is quite an edge case, might be a bug, and I am curious if there is a good solution for this.
@sam I’m tagging you because if anyone should know, I it’s probably you.

Consider a multisite installation.

  1. Forum A is added to the multisite
  2. A plugin that modifies the database is installed (for instance the chat plugin which adds chat_enabled to user_options)
  3. Migrations are run and columns are added to some tables on forum A
  4. The plugin is removed, columns will remain
  5. Forum B is added to the multisite
  6. We now have forum A and forum B on a single multisite with different column definitions in user_options
  7. multisite:seed_fu runs into problems (I think because of ActiveRecord model caching?)
#<ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR:  column user_options.chat_enabled does not exist
LINE 1: ...lendar", "user_options"."oldest_search_log_date", "user_opti...

I’m pretty sure I also ran into this problem when I recently tried to add a new site to a multisite. Thank you for articulating it.

Yeah this is a bit of a nightmare, you are going to need to run cleanup by hand here.

It is critical to have schema parity in all multisite setups.