Skip to content

Commit

Permalink
fix(ActiveRecord): correctly connect to the database in Rails 7.2+
Browse files Browse the repository at this point in the history
  • Loading branch information
markokajzer committed Nov 27, 2024
1 parent c2bc038 commit f464e5e
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
module SlackRubyBotServer
module DatabaseAdapter
def self.check!
ActiveRecord::Base.connection_pool.with_connection(&:active?)
if ActiveRecord::VERSION::STRING >= "7.2"
raise "Database does not exist." unless ActiveRecord::Base.connection.database_exists?
else
ActiveRecord::Base.connection_pool.with_connection(&:active?)
end

raise 'Unexpected error.' unless ActiveRecord::Base.connected?
rescue StandardError => e
warn "Error connecting to PostgreSQL: #{e.message}"
Expand Down

0 comments on commit f464e5e

Please sign in to comment.