Skip to content

Commit

Permalink
Fix #35 - do not register adapter unless on Rails >= 7.2.0 (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
owst authored Sep 9, 2024
1 parent 2402a2d commit dce8532
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/activerecord7-redshift-adapter-pennylane.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ module Activerecord7RedshiftAdapterPennylane
class Railtie < ::Rails::Railtie
initializer "activerecord7-redshift-adapter-pennylane.setup" do
ActiveSupport.on_load(:active_record) do
# The adapter registration API was introduced in Rails 7.2.0 in
# https://github.com/rails/rails/commit/009c7e74117690f0dbe200188a929b345c9306c1
next unless ActiveRecord.version >= Gem::Version.new('7.2.0')

ActiveRecord::ConnectionAdapters.register('redshift', 'ActiveRecord::ConnectionAdapters::RedshiftAdapter')
end
end
Expand Down

0 comments on commit dce8532

Please sign in to comment.