sinatra-activerecord/sinatra-activerecord

DB config hash keys symbolized when received by ActiveRecord (db:schema:load)

rdalverny opened this issue · 0 comments

Symptom

When I try to run rake db:schema:load, nothing happens. Expected behaviour is, well, to load the schema.

Context

I have a Sinatra modular app, using sinatra-activerecord 2.0.9, and activerecord-postgis-adapter 3.1.4, active-record 4.2.6.

Investigation (sort of)

I found that the very task is skipped in ActiveRecord::Tasks::DatabaseTasks#each_current_configuration, because it expects to find configuration['database'], however configuration there only has symbolized keys.

I reproduced this with these 3 configuration ways:

  • using config/database.yml
  • not doing anything and letting sinatra-activerecord fetch ENV['DATABASE_URL']
  • (redundantly) manually assigning through:
db = URI.parse ENV['DATABASE_URL']
set :database, {
  'adapter' => 'postgis',
  'host' => db.host,
  'username' => db.user,
  'password' => db.password,
  'database' => db.path[1..-1],
  'encoding' => 'utf8',
  'postgis_extension' => 'postgis'
}.with_indifferent_access
# no difference with or without .with_indifferent_access,
# and whether keys are symbols or strings there.

It might be obvious, I'm sure it's me, but I am not sure if/what I'm doing wrong in the way I'm setting up my db config; however, the app behaves perfectly well, but for this db:schema:load task - well, db:migrate works ok.

So somewhere along the chain, the hash keys are symbolized; I tried to look if it was in the set :database or in Sinatra::ActiveRecordExtension#database= or into Rack.

Still looking, but any hint is welcome.