Skip to content

Commit

Permalink
We are getting the following error:
Browse files Browse the repository at this point in the history
NoMethodError: undefined method `migration_context' for #<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter:0x0000000000c620

raise ActiveRecord::PendingMigrationError if ActiveRecord::Base.connection.migration_context.needs_migration?

This is because of breaking changes and deprecation in rails 7.2:

ActiveRecord::Base.connection was changed to with_connection:

- https://blog.saeloun.com/2024/07/01/rails-adds-activerecord-base-with-connection/
  • Loading branch information
avinhurry committed Aug 15, 2024
1 parent d92d0b9 commit 281095a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/dfe/analytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,13 @@ def self.initialize!
return
end

raise ActiveRecord::PendingMigrationError if ActiveRecord::Base.connection.migration_context.needs_migration?
if Rails.version.to_i > 7.1
ActiveRecord::Base.with_connection do |connection|
raise ActiveRecord::PendingMigrationError if connection.pool.migration_context.needs_migration?
end
elsif ActiveRecord::Base.connection.migration_context.needs_migration?
raise ActiveRecord::PendingMigrationError
end

DfE::Analytics::Fields.check!

Expand Down

0 comments on commit 281095a

Please sign in to comment.