Skip to content

edge rails (future 7.1) no longer has ActiveRecord::SchemaMigration.table_name #83

@jrochkind

Description

@jrochkind

Current edge rails (future Rails 7.1) produces an error from cleaning in :truncation or :deletion strategies, due to ActiveRecord::SchemaMigration.table_name apparently being removed.

eg

Failure/Error: DatabaseCleaner.clean_with(:truncation)

       NoMethodError:
         undefined method `table_name' for ActiveRecord::SchemaMigration:Class
       # /Users/jrochkind/.gem/ruby/3.0.4/gems/database_cleaner-1.99.0/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/base.rb:73:in `migration_table_name'
       # /Users/jrochkind/.gem/ruby/3.0.4/gems/database_cleaner-1.99.0/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/truncation.rb:271:in `migration_storage_names'
       # /Users/jrochkind/.gem/ruby/3.0.4/gems/database_cleaner-1.99.0/lib/database_cleaner/generic/truncation.rb:14:in `initialize'
       # /Users/jrochkind/.gem/ruby/3.0.4/gems/database_cleaner-1.99.0/adapters/database_cleaner-active_record/lib/database_cleaner/active_record/truncation.rb:238:in `initialize'
       # /Users/jrochkind/.gem/ruby/3.0.4/gems/database_cleaner-1.99.0/lib/database_cleaner/base.rb:128:in `new'
       # /Users/jrochkind/.gem/ruby/3.0.4/gems/database_cleaner-1.99.0/lib/database_cleaner/base.rb:128:in `create_strategy'
       # /Users/jrochkind/.gem/ruby/3.0.4/gems/database_cleaner-1.99.0/lib/database_cleaner/base.rb:75:in `clean_with'
       # /Users/jrochkind/.gem/ruby/3.0.4/gems/database_cleaner-1.99.0/lib/database_cleaner/configuration.rb:93:in `block in clean_with'
       # /Users/jrochkind/.gem/ruby/3.0.4/gems/database_cleaner-1.99.0/lib/database_cleaner/configuration.rb:93:in `each'
       # /Users/jrochkind/.gem/ruby/3.0.4/gems/database_cleaner-1.99.0/lib/database_cleaner/configuration.rb:93:in `clean_with'```

It think possibly this this is the commit where it moved, but still wrapping my head around it: rails/rails@436277d. Hm, it looks like maybe instead of being a class method, SchemaMigration now has to be initialized as an instance with a particular connection to get a table name... this seems unclear how to patch in DC.

It looks like similar things have happened in the past that effected database_cleaner, eg DatabaseCleaner/database_cleaner#476

I run my CI on edge rails to get early notice of anything that will break it... or in this case, early notice of something that broke database_cleaner, preventing me from running my CI on rails edge at present!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions