Closed thedumbtechguy closed 7 months ago
Thank you for the detailed report. This is caused by Rodauth checking the accounts
table schema whether the primary key is an integer, so that it can convert account IDs in tokens. You can have Rodauth skip this query by adding the following to your Rodauth configuration:
convert_token_id_to_integer? true
I will also add this to the default configuration generated by rodauth:install
when UUIDs are not used.
That worked! Thank you very much.
Hello
So I ran into this issue after pulling a fresh copy of my repo. I have a dockerized dev setup so I always need to setup the database again before I can continue. So either your database server is off, or you have not yet created the database can reproduce this issue.
When I execute any rails commands, e.g.
rails db:create
orrails c
, it raisesActiveRecord::ConnectionNotEstablished
(if the server is dead. other errors if the db is not create) because rodauth-rails is attempting to fetch some metadata from the database.You can only get past it by commenting out
configure RodauthAccount
andinclude Rodauth::Rails.model
calls.The problem occurs because the rodauth files are autoloaded by rails, and during this, the calls above are evaluated. During both of these, there is an attempt to introspect the database leading to the failure.
Full Stack Trace
``` /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql_adapter.rb:87:in `rescue in new_client': connection to server at "127.0.0.1", port 5432 failed: FATAL: could not open file "global/pg_filenode.map": Operation not permitted (ActiveRecord::ConnectionNotEstablished) from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql_adapter.rb:77:in `new_client' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:656:in `public_send' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:656:in `new_connection' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:700:in `checkout_new_connection' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:679:in `try_to_checkout_new_connection' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:640:in `acquire_connection' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:341:in `checkout' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:181:in `connection' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_adapters/abstract/connection_handler.rb:211:in `retrieve_connection' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_handling.rb:313:in `retrieve_connection' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activerecord-7.0.7.2/lib/active_record/connection_handling.rb:280:in `connection' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sequel-activerecord_connection-1.3.1/lib/sequel/extensions/activerecord_connection.rb:178:in `activerecord_connection' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sequel-activerecord_connection-1.3.1/lib/sequel/extensions/activerecord_connection.rb:165:in `activerecord_lock' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sequel-activerecord_connection-1.3.1/lib/sequel/extensions/activerecord_connection.rb:37:in `synchronize' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sequel-activerecord_connection-1.3.1/lib/sequel/extensions/activerecord_connection/postgres.rb:7:in `synchronize' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sequel-5.74.0/lib/sequel/database/transactions.rb:197:in `transaction' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sequel-activerecord_connection-1.3.1/lib/sequel/extensions/activerecord_connection/postgres.rb:28:in `transaction' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sequel-5.74.0/lib/sequel/database/query.rb:206:in `table_exists?' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rodauth-2.32.0/lib/rodauth/features/base.rb:431:in `post_configure' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rodauth-2.32.0/lib/rodauth/features/email_base.rb:22:in `post_configure' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rodauth-2.32.0/lib/rodauth/features/internal_request.rb:383:in `post_configure' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rodauth-2.32.0/lib/rodauth/features/path_class_methods.rb:6:in `post_configure' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rodauth-2.32.0/lib/rodauth.rb:64:in `configure' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/roda-3.74.0/lib/roda.rb:300:in `plugin' from /Users/me/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rodauth-rails-1.12.0/lib/rodauth/rails/app.rb:33:in `configure' from /Users/me/code/plutonium/my_app/app/misc/rodauth_app.rb:5:in `