mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: fallback to custom type for flags (#27961)
Before migration is run flags code is evaluated. It is causing error: ``` NoMethodError: undefined method `require_message' for an instance of Flag (NoMethodError) Did you mean? require_dependency /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/activemodel-7.1.3.4/lib/active_model/attribute_methods.rb:489:in `method_missing' /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/activerecord-7.1.3.4/lib/active_record/relation/delegation.rb💯in `each' /var/www/discourse/vendor/bundle/ruby/3.3.0/gems/activerecord-7.1.3.4/lib/active_record/relation/delegation.rb💯in `each' /var/www/discourse/app/models/post_action_type.rb:64:in `reject' ``` The solution is to temporarily fall back to old column name - custom_type
This commit is contained in:
parent
c7b458931a
commit
7b6b7ca863
@ -1,9 +1,6 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Flag < ActiveRecord::Base
|
class Flag < ActiveRecord::Base
|
||||||
# TODO(2025-01-15): krisk remove
|
|
||||||
self.ignored_columns = ["custom_type"]
|
|
||||||
|
|
||||||
DEFAULT_VALID_APPLIES_TO = %w[Post Topic]
|
DEFAULT_VALID_APPLIES_TO = %w[Post Topic]
|
||||||
MAX_SYSTEM_FLAG_ID = 1000
|
MAX_SYSTEM_FLAG_ID = 1000
|
||||||
MAX_NAME_LENGTH = 200
|
MAX_NAME_LENGTH = 200
|
||||||
@ -26,6 +23,15 @@ class Flag < ActiveRecord::Base
|
|||||||
Set.new(DEFAULT_VALID_APPLIES_TO | DiscoursePluginRegistry.flag_applies_to_types)
|
Set.new(DEFAULT_VALID_APPLIES_TO | DiscoursePluginRegistry.flag_applies_to_types)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO(2025-01-15): krisk remove
|
||||||
|
def require_message
|
||||||
|
if ActiveRecord::Base.connection.column_exists?(:flags, :require_message)
|
||||||
|
super
|
||||||
|
else
|
||||||
|
self.custom_type
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.reset_flag_settings!
|
def self.reset_flag_settings!
|
||||||
# Flags are memoized for better performance. After the update, we need to reload them in all processes.
|
# Flags are memoized for better performance. After the update, we need to reload them in all processes.
|
||||||
PostActionType.reload_types
|
PostActionType.reload_types
|
||||||
|
Loading…
Reference in New Issue
Block a user