Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jrochkind opened this issue Sep 12, 2022 · 4 comments

Comments

@jrochkind
Copy link
Contributor

jrochkind commented Sep 12, 2022

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!

@bdewater
Copy link

bdewater commented Nov 1, 2022

FWIW Rails 6 shipped with a db:truncate_all task, you can add in your test helper for the same effect (docs):

teardown do
  ActiveRecord::Tasks::DatabaseTasks.truncate_all
end

@brian-kephart
Copy link

Looks like the source of the issue is a dependent gem, which now has an open PR. See 19327d1

@sebaherrera07
Copy link

Looks like the source of the issue is a dependent gem, which now has an open PR. See DatabaseCleaner/database_cleaner-active_record@19327d1

Nice. I saw the PR was opened in early December and didn't have any more activity, so I opened a new PR: #80 . Hope it works and we can get this issue resolved 🙏

@etagwerker etagwerker transferred this issue from DatabaseCleaner/database_cleaner Mar 10, 2023
@etagwerker
Copy link
Member

jxjj added a commit to UMN-LATIS/z that referenced this issue Apr 19, 2024
…emaMigration:Class'`

Cypress tests fail immediately with:
```
undefined method 'table_name' for ActiveRecord::SchemaMigration:Class'
```

Issue described here:
DatabaseCleaner/database_cleaner-active_record#83

Updating to the latest database-cleaner gem.
markokajzer added a commit to markokajzer/slack-ruby-bot-server that referenced this issue Nov 30, 2024
ci: add active_record 7.2 to ci matrix
deps: pin pagy_cursor to prevent incompatible version
deps: pin activerecord 7.2+ compatible version of database_cleaner

ran into DatabaseCleaner/database_cleaner-active_record#83
markokajzer added a commit to markokajzer/slack-ruby-bot-server that referenced this issue Nov 30, 2024
ci: add active_record 7.2 to ci matrix
deps: pin pagy_cursor to prevent incompatible version
deps: pin activerecord 7.2+ compatible version of database_cleaner

ran into DatabaseCleaner/database_cleaner-active_record#83
markokajzer added a commit to markokajzer/slack-ruby-bot-server that referenced this issue Nov 30, 2024
ci: add active_record 7.2 to ci matrix
deps: pin pagy_cursor to prevent incompatible version
deps: pin activerecord 7.2+ compatible version of database_cleaner

ran into DatabaseCleaner/database_cleaner-active_record#83
dblock pushed a commit to slack-ruby/slack-ruby-bot-server that referenced this issue Dec 2, 2024
* fix(ActiveRecord): correctly connect to the database in Rails 7.2+

ci: add active_record 7.2 to ci matrix
deps: pin pagy_cursor to prevent incompatible version
deps: pin activerecord 7.2+ compatible version of database_cleaner

ran into DatabaseCleaner/database_cleaner-active_record#83

* chore: skip activerecord specs on mongoid

* deps: use correct database_cleaner adapter per database

* deps: pin mongoid-scroll to v1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants