colio303 colio303 - 1 month ago 10
Ruby Question

db:schema:dump on RDS with mysql. Error: Could not dump table "" because of following NoMethodError undefined method `type' for "int(11)":String

Setup:


rails: 4.2.5.1

ruby: 2.2.4p230 (2015-12-16 revision 53155) [i386-mingw32]

windows 7 environment


database.yml:

default: &default
adapter: mysql2
encoding: utf8
database: "database"
username: "name"
password: "password"
host: "host"
port: 3306

development:
adapter: mysql2
encoding: utf8
database: "database"
username: "name"
password: "password"
host: "host"
port: 3306


I am trying to use an existing mysql database on RDS. I created a new project using

rails new "app"
and then attempted to get the database schema.
When I run

ruby bin\rake db:schema:dump
the output in my schema.rb file is filled with the same error for every table in the database:

ActiveRecord::Schema.define() do
# Could not dump table "test" because of following NoMethodError
# undefined method `type' for "int(11)":String
end


I first thought that maybe it was because int(11) was a 64 bit integer, but later learned that the "11" in int(11) refers to the display size, and that it is still a 32 bit integer.

Can anyone explain why this is happening or why ruby doesn't recognize the 32 bit integer type for the primary key column.

Answer

I managed to get rid of this error by making the following changes to my Gemfile.

gem 'mysql2', '~>0.3.13'
#gem 'activerecord-mysql2-adapter'

Then I ran bundle install to update my gems.

I am still not sure why this worked.

Comments