activerecord-cockroachdb-adapter icon indicating copy to clipboard operation
activerecord-cockroachdb-adapter copied to clipboard

Rails 7 version throws "PG::UndefinedObject"

Open aemadrid-twx opened this issue 2 years ago • 7 comments

❯ bundle show activerecord-cockroachdb-adapter
/Users/some_user/.asdf/installs/ruby/3.1.1/lib/ruby/gems/3.1.0/gems/activerecord-cockroachdb-adapter-7.0.0

❯ bundle show rails
/Users/some_user/.asdf/installs/ruby/3.1.1/lib/ruby/gems/3.1.0/gems/rails-7.0.3.1

❯ ruby -v
ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [arm64-darwin21]

❯  be rake db:create
Created database 'some_app_development'
PG::UndefinedObject: ERROR:  unrecognized configuration parameter "crdb_version"
Couldn't create 'some_app_development' database. Please check your configuration.
rake aborted!
ActiveRecord::ConnectionNotEstablished: PG::UndefinedObject: ERROR:  unrecognized configuration parameter "crdb_version"
/Users/some_user/.asdf/installs/ruby/3.1.1/bin/bundle:25:in `load'
/Users/some_user/.asdf/installs/ruby/3.1.1/bin/bundle:25:in `<main>'

aemadrid-twx avatar Jul 22 '22 00:07 aemadrid-twx

Could you share your CockroachDB version and your rails database configuration (or URL) you used to connect?

rafiss avatar Jul 22 '22 01:07 rafiss

Cockroach V22.1.4

default: &default
  adapter: cockroachdb
  encoding: utf8
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
  <<: *default
  database: some_app_development
  host: localhost
  port: 26257
  user: root
  password: ""
  sslmode: disable

aemadrid-twx avatar Jul 22 '22 03:07 aemadrid-twx

BTW tested this in a Rails 6 app with the 6.1.10 adapter and it works as expected.

❯ bundle exec rake db:create
Created database 'some_app_development'
Created database 'some_app_test'

❯ ruby -v
ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [arm64-darwin21]

❯ bundle show rails
/Users/some_user/.asdf/installs/ruby/3.1.1/lib/ruby/gems/3.1.0/gems/rails-6.1.6.1

❯ bundle show activerecord-cockroachdb-adapter
/Users/some_user/.asdf/installs/ruby/3.1.1/lib/ruby/gems/3.1.0/gems/activerecord-cockroachdb-adapter-6.1.10

aemadrid-twx avatar Jul 22 '22 17:07 aemadrid-twx

I haven't been able to reproduce this. If possible, could you upload your code to a repo or a gist so i can try running it myself?

The unrecognized configuration parameter "crdb_version" error makes me think that it's somehow connecting to Postgres instead of CRDB.

rafiss avatar Aug 04 '22 17:08 rafiss

I'm having the same issue with Rails 7.

$ bundle exec rake db:create
PG::UndefinedObject: ERROR:  unrecognized configuration parameter "crdb_version"
Couldn't create 'defaultdb' database. Please check your configuration.

Using gem "activerecord-cockroachdb-adapter", "~> 7.0.0" in Gemfile

database.yml

default: &default
  adapter: cockroachdb
  url: <%= ENV['ADAMSGPT_COCKROACHDB_DATABASE_URL'] %>
  database: defaultdb
  sslrootcert: './.postgresql/root.crt'
  sslmode: verify-full
 
development:
  <<: *default
 
production:
  <<: *default

adamjgrant avatar Mar 19 '23 15:03 adamjgrant

bundle show activerecord-cockroachdb-adapter
/Users/adamgrant/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-cockroachdb-adapter-7.0.0

bundle show rails
/Users/adamgrant/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rails-7.0.4.3

ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [arm64-darwin22]

adamjgrant avatar Mar 19 '23 15:03 adamjgrant

Strangely I ran it again today and it worked just fine. 🤷🏻

adamjgrant avatar Mar 20 '23 19:03 adamjgrant