FIX: Use proper ActiveRecord method in import scripts

`ActiveRecord::Base.connection_config` has been deprecated since Rails
6.1 and was completely removed from Rails 7.
Instead we need to use
`ActiveRecord::Base.connection_db_config.configuration_hash`.

Import scripts were forgotten when we did the Rails 7 upgrade, this
patch fixes them.
This commit is contained in:
Loïc Guitaut 2022-05-09 10:49:13 +02:00 committed by Loïc Guitaut
parent c05dc01fe9
commit ab6ca78486
2 changed files with 2 additions and 2 deletions

View File

@ -74,7 +74,7 @@ class BulkImport::Base
def initialize
charset = ENV["DB_CHARSET"] || "utf8"
db = ActiveRecord::Base.connection_config
db = ActiveRecord::Base.connection_db_config.configuration_hash
@encoder = PG::TextEncoder::CopyRow.new
@raw_connection = PG.connect(dbname: db[:database], port: db[:port])
@uploader = ImportScripts::Uploader.new

View File

@ -18,7 +18,7 @@ class BulkImport::DiscourseMerger < BulkImport::Base
def initialize
db_password = ENV["DB_PASS"] || 'import_password'
local_db = ActiveRecord::Base.connection_config
local_db = ActiveRecord::Base.connection_db_config.configuration_hash
@raw_connection = PG.connect(dbname: local_db[:database], host: 'localhost', port: local_db[:port], user: 'postgres', password: db_password)
@source_db_config = {