Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use lease_connection over deprecated connection for rails 8 #353

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/data_migrate/database_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ module DatabaseTasks
extend ActiveRecord::Tasks::DatabaseTasks
extend self

if respond_to?(:register_task)
register_task(/mysql/, "ActiveRecord::Tasks::MySQLDatabaseTasks")
register_task(/trilogy/, "ActiveRecord::Tasks::MySQLDatabaseTasks")
register_task(/postgresql/, "ActiveRecord::Tasks::PostgreSQLDatabaseTasks")
register_task(/sqlite/, "ActiveRecord::Tasks::SQLiteDatabaseTasks")
end

# These method are only introduced in Rails 7.1
unless respond_to?(:with_temporary_pool_for_each)
def with_temporary_pool_for_each(env: ActiveRecord::Tasks::DatabaseTasks.env, name: nil, &block) # :nodoc:
Expand Down Expand Up @@ -219,7 +226,7 @@ def self.prepare_all_with_data
next unless primary?(db_config)

with_temporary_pool(db_config) do |pool|
unless database_exists?(pool.connection)
unless database_exists?(pool.lease_connection)
create(db_config)
if File.exist?(schema_dump_path(db_config))
load_schema(db_config, schema_format, nil)
Expand Down
Loading