Skip to content

Fix error that undefined method `schema_format' in AR 7.1#2300

Open
matsubara0507 wants to merge 3 commits intopadrino:masterfrom
matsubara0507:fix-schema_format-ar71
Open

Fix error that undefined method `schema_format' in AR 7.1#2300
matsubara0507 wants to merge 3 commits intopadrino:masterfrom
matsubara0507:fix-schema_format-ar71

Conversation

@matsubara0507
Copy link

Error occurred when invoke ar:migrate:redo in AR 7.1:

% bundle exec rake ar:migrate:redo MIGRATION_VERSION=1234
...
rake aborted!
NoMethodError: undefined method `schema_format' for ActiveRecord::Base:Class (NoMethodError)
/path/to/vendor/gems/ruby/3.2.0/gems/activerecord-7.1.5.1/lib/active_record/dynamic_matchers.rb:22:in `method_missing'
/path/to/vendor/gems/ruby/3.2.0/gems/padrino-gen-0.16.0.pre3/lib/padrino-gen/padrino-tasks/activerecord.rb:412:in `dump_schema'
/path/to/vendor/gems/ruby/3.2.0/gems/padrino-gen-0.16.0.pre3/lib/padrino-gen/padrino-tasks/activerecord.rb:394:in `migrate_as'
/path/to/vendor/gems/ruby/3.2.0/gems/padrino-gen-0.16.0.pre3/lib/padrino-gen/padrino-tasks/activerecord.rb:165:in `block (3 levels) in <top (required)>'
/path/to/vendor/gems/ruby/3.2.0/gems/padrino-gen-0.16.0.pre3/lib/padrino-gen/padrino-tasks/activerecord.rb:150:in `block (3 levels) in <top (required)>'
/path/to/vendor/gems/ruby/3.2.0/gems/rake-13.2.1/exe/rake:27:in `<top (required)>'
...

So I fixed it the same way as #2275

@jkowens
Copy link
Collaborator

jkowens commented Feb 5, 2025

It might be worth considering adding a method schema_format_ruby?:

def schema_format_ruby?
  schema_format = if less_than_active_record_7_0?
      ActiveRecord::Base.schema_format
  else
    ActiveRecord.schema_format
  end
  schema_format == :ruby
end

Then dump_schema would be:

def dump_schema
  Rake::Task["ar:schema:dump"].invoke if schema_format_ruby?
end

@matsubara0507
Copy link
Author

I Added schema_format_ruby?.
Thanks!

@crashtech
Copy link
Collaborator

This should be fixed on version 0.16.0.pre4. Could you please check?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants