I’m trying to migrate a working app from Postgres to MySQL, and I’m
trying to use a migration to get it done rather than alter all my
database table creation scripts to MySQL syntax. I’ve done loads of
work with Postgres, but am a real newbie with MySQL…
I did a ‘rake db_schema_dump’ from my Postgres app, and got a nice
looking schema file with all my tables and fields, exactly as
expected. I then created a migration file, pasted the schema info
into the self.up section in the schema file and made sure there were
no obvious problems. So far, so good.
I then did a ‘gem install mysql’, created a new MySQL database, set up
a MySQL user, tweaked database.yml to point to the new MySQL database
and tried a ‘rake db_schema_import’.
Wham! Loads of warnings, ending in an ‘uninitialized constant Mysql’.
I’ve confirmed that the database.yml file is OK. I then did a ‘rake
db_schema_import --trace’; here’s what I think is the relevant section
of the output:
** Invoke db_schema_import (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db_schema_import
uninitialized constant Mysql
method_missing' ./db/schema.rb:7 /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/schema.rb:43:indefine’
load' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/tasks/databases.rake:27 /usr/lib/ruby/site_ruby/1.8/rake.rb:232:inexecute’
I poked around in Google and found a few people have seen the
‘uninitialized constant Mysql’ error, but these always seem to be due
to using old versions of Rails, gems or MySQL. I’m running the latest
Rails, just updated all gems, and MySQL 5.1, so I can’t see that I’ve
got any old stuff left.
Has anyone got any suggestions?
Thanks in advance