discourse/app/models/concerns/has_deprecated_columns.rb
David Taylor 88305e3d96
DEV: Remove version-number-based logic (#25482)
The `deprecate_column` helper would change its behavior based on the current `Discourse::VERSION`. This means that 'finalizing' a stable release introduces a previously untested behavior change.

Much better to keep it as a deprecation until manual action is taken to introduce the breaking change.
2024-01-30 17:34:10 +00:00

22 lines
605 B
Ruby

# frozen_string_literal: true
module HasDeprecatedColumns
extend ActiveSupport::Concern
class_methods do
def deprecate_column(column_name, drop_from:, raise_error: false, message: nil)
message = message.presence || "column `#{column_name}` is deprecated."
define_method(column_name) do
Discourse.deprecate(message, drop_from: drop_from, raise_error: raise_error)
super()
end
define_method("#{column_name}=") do |value|
Discourse.deprecate(message, drop_from: drop_from, raise_error: raise_error)
super(value)
end
end
end
end