Search code examples
mysqlruby-on-rails-4rakebundlerdbmigrate

MySQL & Rails 4 - bundle exec rake db:migrate - Unsupported database for migration to UTF-8


I have a Ruby on Rails 4 app that I have cloned from Github and am trying to get up and running on my MacBook in a dev environment.

Initially the app complained about not finding MySQL, so I did brew install mysql. I now have mysqld running with username root and no password and the app is able to connect to it, so I got past the first hump.

The schema hasn't been built in the database yet, though -- and I can see about 115 files in the db/migrate/ directory with names like 004_make_unicode_fiendly.rb and 016_add_asin_column.rb.

I tried to run bundle exec rake db:migrate, but I got an error after the first three migration files apparently ran successfully:

Migration error: Unsupported database for migration to UTF-8 support
/Users/jon/work/amazing_app/db/migrate/004_make_unicode_friendly.rb:22:in `alter_database_and_tables_charsets'
/Users/jon/work/amazing_app/db/migrate/004_make_unicode_friendly.rb:3:in `up'

running mysqladmin variables | grep utf8 shows:

| character_set_client                               | utf8
| character_set_connection                           | utf8
| character_set_database                             | utf8
| character_set_results                              | utf8
| character_set_server                               | utf8
| character_set_system                               | utf8
| collation_connection                               | utf8_general_ci
| collation_database                                 | utf8_general_ci
| collation_server                                   | utf8_general_ci

My question: why am I getting a migration error here?


Solution

  • Answer as discussed: - Execute (bundle exec rake) db:create, db:reset

    This will create the DB using your seeds and schema as they are on the other machine. Not knowing the specific error details I can't comment on why you received the error in the first place (unless it's saying you can't migrate to UTF-8 because you already are on UTF-8).

    FYI that DB:Migrate should not be necessary unless your existing code base had an pending migration.