Skip to content

Commit f464e5e

Browse files
committed
fix(ActiveRecord): correctly connect to the database in Rails 7.2+
1 parent c2bc038 commit f464e5e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
module SlackRubyBotServer
77
module DatabaseAdapter
88
def self.check!
9-
ActiveRecord::Base.connection_pool.with_connection(&:active?)
9+
if ActiveRecord::VERSION::STRING >= "7.2"
10+
raise "Database does not exist." unless ActiveRecord::Base.connection.database_exists?
11+
else
12+
ActiveRecord::Base.connection_pool.with_connection(&:active?)
13+
end
14+
1015
raise 'Unexpected error.' unless ActiveRecord::Base.connected?
1116
rescue StandardError => e
1217
warn "Error connecting to PostgreSQL: #{e.message}"

0 commit comments

Comments
 (0)