schema.rb - dump errors - NoMethodError undefined method `default_function'

1.1k Views Asked by At

I went to look at my schema.rb file and found the following:

ActiveRecord::Schema.define(version: 20140729164926) do

# Could not dump table "account_services_indices" because of following NoMethodError
#   undefined method `default_function' for
#<ActiveRecord::ConnectionAdapters::PostgreSQLColumn:0x757a77>
...

Those last three lines are repeated for every table in the database!

The database seems to be working fine. I can do a db:rollback and db:migrate with no problem except that the regenerated schema.rb still looks like the above. Looking back through my GIT repository, it happened about 7/29/14. The only other db related change in that commit was a minor migration, adding a column to each of two tables. I tried a db:rollback, then db:schema:dump, but no luck. Other commits at that point were changes to views and controllers only.

I'm using the 'activerecord-jdbcpostgresql-adapter' gem. Version 1.3.9 was released July 7, 2014. Forced that back to version 1.3.8 in the Gemfile, bundled and tried db:schema:dump again, but still the same thing. Dropping the database and starting over might work and wouldn't be catastrophic, but I hate to lose all my development data right now.

Renamed the database in database.yml. Created that new database and built it out with db:migrate. Resulting schema.rb is still a list of the same errors.

Any suggestions?

1

There are 1 best solutions below

0
On

Solved it!

I'm still not sure of the exact cause but here's my resolution. I created a rails app from scratch called Blog, then started to replicate the gems I'm using in the real application. The test app was generated with

gem 'rails', '4.1.4'

and worked with no problem. I changed that to

gem 'rails', '4.0.0'

to match my real app and did a bundle update and bundle install. Doing a rake db:schema:dump then gave me the following error:

rake aborted!
NoMethodError: undefined method `configure' for #<Blog::Application:0x6932cb>
/home/mpipkorn/rails_projects/blog/config/environments/development.rb:1:in `(root)'
/home/mpipkorn/rails_projects/blog/config/environment.rb:5:in `(root)'
Tasks: TOP => db:schema:dump => environment

Following a lead in StackOverflow, I did the following:

Change the first line in app/config/initializers/development.rb from

Rails.application.configure do

to

Blog::Application.configure do

That matches the format in my real app. I did rake db:schema:dump again. This time the rake task ran with no errors, but looking at the resulting schema.rb file, I see

ActiveRecord::Schema.define(version: 20140806174338) do

# Could not dump table "articles" because of following NoMethodError
#   undefined method `default_function' for #<ActiveRecord::ConnectionAdapters::PostgreSQLColumn:0x183e66e>

end

Changing the Blog Gemfile (back) to

gem 'rails', '4.1.4'

and doing a bundle update and bundle install, then doing a rake db:schema:dump now results in a normal looking schema.rb file with no error messages!

The bottom line is that changing the rails gem from 4.0.0 to 4.1.4 in my real application solved my problem. What exactly caused this to begin with I'm still not certain, but an update along the way seems to be at fault and there are certain version combinations of gems that don't work, perhaps the combination of activerecord-jdbcpostgresql-adapter 1.3.9 with Rails 4.0.0.