rubyforgood / human-essentials

Human Essentials is an inventory management system for diaper, incontinence, and period-supply banks. It supports them in distributing to partners, tracking inventory, and reporting stats and analytics.
https://humanessentials.app
MIT License
436 stars 449 forks source link

bin/setup broken (as of rails 7.1.3.2) #4373

Closed cielf closed 1 month ago

cielf commented 1 month ago

Summary

When running bin/setup on the current main, it breaks when attempting to drop the databasse.

Things to consider

Here are the details:
undefined local variable or method establish_master_connection’ for #<ActiveRecord::Tasks::PostgreSQLDatabaseTasks:0x000000011e9e2450 @db_config=#<ActiveRecord::DatabaseConfigurations::HashConfig:0x000000011d9028b0 @env_name=“development”, @name=“primary”, @configuration_hash={:adapter=>“postgresql”, :encoding=>“unicode”, :host=>nil, :database=>“diaper_dev”, :username=>nil, :password=>nil, :pool=>5, :timeout=>5000}>, @configuration_hash={:adapter=>“postgresql”, :encoding=>“unicode”, :host=>nil, :database=>“diaper_dev”, :username=>nil, :password=>nil, :pool=>5, :timeout=>5000}> Couldn’t drop database ‘diaper_dev’ bin/rails aborted! NameError: undefined local variable or methodestablish_master_connection’ for #<ActiveRecord::Tasks::PostgreSQLDatabaseTasks:0x000000011e9e2450 @db_config=#<ActiveRecord::DatabaseConfigurations::HashConfig:0x000000011d9028b0 @env_name=“development”, @name=“primary”, @configuration_hash={:adapter=>“postgresql”, :encoding=>“unicode”, :host=>nil, :database=>“diaper_dev”, :username=>nil, :password=>nil, :pool=>5, :timeout=>5000}>, @configuration_hash={:adapter=>“postgresql”, :encoding=>“unicode”, :host=>nil, :database=>“diaper_dev”, :username=>nil, :password=>nil, :pool=>5, :timeout=>5000}> (NameError) establish_master_connection ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Did you mean? establish_connection /Users/clfisher/projects/human-essentials/config/initializers/postgres.rb:7:in `drop’ Tasks: TOP => db:drop:_unsafe (See full trace by running task with --trace) == Command [“bin/rails db:reset”] failed ==“(edited)

IIUC , we are overriding ActiveRecord::Tasks::PostgreSQLDatabaseTasks.drop in config/initializers/postgres.rb in development and test.
Our override calls establish_master_connection. This https://apidock.com/rails/v7.1.3.2/ActiveRecord/Tasks/PostgreSQLDatabaseTasks seems to suggest that establish_master_connection is no longer a thing. It lists a newish method: establish_connection which one might surmise is a replacement.

Criteria for Completion

elasticspoon commented 1 month ago

I think that initializer can probably be dropped. Based on https://github.com/rubyforgood/human-essentials/pull/53/commits/87db6dfb53fa6fea9f18400ad01115371577c5c8 the commit that added it, it seems like it was meant to be used with pow.cx.

I have no clue what that is. But based on the website being dead http://get.pow.cx/ I'm assuming that project is no longer being worked on.

cielf commented 1 month ago

FYI Apparently it is/was "A zero-config Rack server for Mac OS X. It is a self-contained server that runs as a user without root privileges."
The reposotiry for it (basecamp/pow) was archived in 2020. (https://github.com/basecamp/pow)

I too, expect we've moved on, and that this overriding could be yanked.

elasticspoon commented 1 month ago

https://github.com/rubyforgood/human-essentials/pull/4376 i think that will do it