mirror of
https://github.com/discourse/discourse.git
synced 2025-03-03 09:47:41 +08:00

Unfortunately, Discourse's `UserOption` model is not currently autoloaded. That means that modifying it via a `reloadable_patch` will try to apply the changes repeatedly. Normally this doesn't matter since the changes are idempotent. However, introducing ActiveRecord enums is not idempotent - they raise an error if the same enum already exists on the model. This commit adds a check to avoid hitting this 'duplicate definition' error. Reproduced ``` rails runner 'Rails.application.reloader.reload!' ```