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

fix(#4373): remove legacy postgres initializer #4376

Merged
merged 1 commit into from
May 22, 2024

Conversation

elasticspoon
Copy link
Collaborator

Fixes #4373

Application had a legacy hack to forcefully drop DB connections that was needed with pow.cx.

That is no longer used and the hack no longer work with Rails 7.1 so the initializer can be removed.

Can confirm it happens on main for me without the fix:

$ > rails db:reset
undefined local variable or method `establish_master_connection' for #<ActiveRecord::Tasks::PostgreSQLDatabaseTasks:0x00007f1e4e8619b0 @db_config=#<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007f1e4ee59930 @env_name="development", @name="primary", @configuration_hash={:adapter=>"postgresql", :encoding=>"unicode", :host=>"localhost", :database=>"diaper_dev", :username=>"postgres", :password=>"postgres", :pool=>5, :timeout=>5000}>, @configuration_hash={:adapter=>"postgresql", :encoding=>"unicode", :host=>"localhost", :database=>"diaper_dev", :username=>"postgres", :password=>"postgres", :pool=>5, :timeout=>5000}>
Couldn't drop database 'diaper_dev'
bin/rails aborted!
NameError: undefined local variable or method `establish_master_connection' for #<ActiveRecord::Tasks::PostgreSQLDatabaseTasks:0x00007f1e4e8619b0 @db_config=#<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007f1e4ee59930 @env_name="development", @name="primary", @configuration_hash={:adapter=>"postgresql", :encoding=>"unicode", :host=>"localhost", :database=>"diaper_dev", :username=>"postgres", :password=>"postgres", :pool=>5, :timeout=>5000}>, @configuration_hash={:adapter=>"postgresql", :encoding=>"unicode", :host=>"localhost", :database=>"diaper_dev", :username=>"postgres", :password=>"postgres", :pool=>5, :timeout=>5000}> (NameError)

          establish_master_connection
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Did you mean?  establish_connection
/home/bandito/Projects/rfg-human-essentials-fork/config/initializers/postgres.rb:7:in `drop'
Tasks: TOP => db:drop:_unsafe
(See full trace by running task with --trace)

and works fine with the fix:

$ > rails db:reset
Dropped database 'diaper_dev'
Dropped database 'diaper_test'
Created database 'diaper_dev'
Created database 'diaper_test'
loading US counties and equivalents.

Application had a legacy hack to forcefull drop DB
connections that was needed with pow.cx.

That is no longer used and the hack no longer work with
Rails 7.1 so the initializer can be removed.
@elasticspoon elasticspoon marked this pull request as ready for review May 22, 2024 00:10
@dorner dorner merged commit 2a0d273 into rubyforgood:main May 22, 2024
19 checks passed
@dorner
Copy link
Collaborator

dorner commented May 22, 2024

Thanks!

Copy link
Contributor

@elasticspoon: Your PR fix(#4373): remove legacy postgres initializer is part of today's Human Essentials production release: 2024.05.26.
Thank you very much for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bin/setup broken (as of rails 7.1.3.2)
2 participants