Issue when doing data migration on CI
borisrorsvort opened this issue · 3 comments
borisrorsvort commented
I’m getting Mobility::Plugins::Attributes::FrozenAttributesError: Attempting to translate these attributes on Post, which has already been subclassed: title.
Using ActiveRecord with rails 7 here.
Examble migration triggering that error on CI:
class MigrateFromApplicationFileTemplate < ActiveRecord::Migration[7.0]
def up
Post.where(any_attribute: 3).update_all(any_attribute: 1)
end
end
Redefining model in migration solves this issue:
class MigrateFromApplicationFileTemplate < ActiveRecord::Migration[7.0]
def Post < ApplicationRecord
end
def up
Post.where(any_attribute: 3).update_all(any_attribute: 1)
end
end
Trace
Attempting to translate these attributes on Post, which has already been subclassed: title.
274
/home/runner/work/my_company/my_company/vendor/bundle/ruby/2.7.0/gems/mobility-1.2.6/lib/mobility/plugins/attributes.rb:36:in `rescue in block (2 levels) in <module:Attributes>'
275
/home/runner/work/my_company/my_company/vendor/bundle/ruby/2.7.0/gems/mobility-1.2.6/lib/mobility/plugins/attributes.rb:32:in `block (2 levels) in <module:Attributes>'
276
/home/runner/work/my_company/my_company/vendor/bundle/ruby/2.7.0/gems/mobility-1.2.6/lib/mobility/plugins/attributes.rb:31:in `class_eval'
277
/home/runner/work/my_company/my_company/vendor/bundle/ruby/2.7.0/gems/mobility-1.2.6/lib/mobility/plugins/attributes.rb:31:in `block in <module:Attributes>'
278
/home/runner/work/my_company/my_company/vendor/bundle/ruby/2.7.0/gems/mobility-1.2.6/lib/mobility/plugin.rb:88:in `class_exec'
279
/home/runner/work/my_company/my_company/vendor/bundle/ruby/2.7.0/gems/mobility-1.2.6/lib/mobility/plugin.rb:88:in `block (2 levels) in included_hook'
280
/home/runner/work/my_company/my_company/vendor/bundle/ruby/2.7.0/gems/mobility-1.2.6/lib/mobility/plugin.rb:86:in `tap'
281
/home/runner/work/my_company/my_company/vendor/bundle/ruby/2.7.0/gems/mobility-1.2.6/lib/mobility/plugin.rb:86:in `block in included_hook'
282
/home/runner/work/my_company/my_company/vendor/bundle/ruby/2.7.0/gems/mobility-1.2.6/lib/mobility/plugins/backend.rb:43:in `included'
283
/home/runner/work/my_company/my_company/vendor/bundle/ruby/2.7.0/gems/mobility-1.2.6/lib/mobility/plugin.rb:86:in `block in included_hook'
284
/home/runner/work/my_company/my_company/vendor/bundle/ruby/2.7.0/gems/mobility-1.2.6/lib/mobility/plugin.rb:86:in `block in included_hook'
285
/home/runner/work/my_company/my_company/vendor/bundle/ruby/2.7.0/gems/mobility-1.2.6/lib/mobility/plugin.rb:86:in `block in included_hook'
286
/home/runner/work/my_company/my_company/vendor/bundle/ruby/2.7.0/gems/mobility-1.2.6/lib/mobility/plugin.rb:86:in `block in included_hook'
287
/home/runner/work/my_company/my_company/vendor/bundle/ruby/2.7.0/gems/mobility-1.2.6/lib/mobility/plugin.rb:86:in `block in included_hook'
288
/home/runner/work/my_company/my_company/vendor/bundle/ruby/2.7.0/gems/mobility-1.2.6/lib/mobility/plugin.rb:86:in `block in included_hook'
289
/home/runner/work/my_company/my_company/vendor/bundle/ruby/2.7.0/gems/mobility-1.2.6/lib/mobility/plugin.rb:86:in `block in included_hook'
290
/home/runner/work/my_company/my_company/vendor/bundle/ruby/2.7.0/gems/mobility-1.2.6/lib/mobility/plugin.rb:86:in `block in included_hook'
291
/home/runner/work/my_company/my_company/vendor/bundle/ruby/2.7.0/gems/mobility-1.2.6/lib/mobility/plugin.rb:86:in `block in included_hook'
292
/home/runner/work/my_company/my_company/vendor/bundle/ruby/2.7.0/gems/mobility-1.2.6/lib/mobility.rb:98:in `include'
293
/home/runner/work/my_company/my_company/vendor/bundle/ruby/2.7.0/gems/mobility-1.2.6/lib/mobility.rb:98:in `translates'
294
/home/runner/work/my_company/my_company/app/models/post.rb:20:in `<class:Post>'
295
/home/runner/work/my_company/my_company/app/models/post.rb:3:in `<main>'
shioyama commented
Does Post
have a subclass somewhere? That's what the error is indicating.
shioyama commented
Unfortunately unless there's a way to reproduce the issue, there's not much I can do. Closing for now.
borisrorsvort commented
Does
Post
have a subclass somewhere? That's what the error is indicating.
Yes it has a subclass, many actually