views:

56

answers:

4

I'm trying to get a database populate so I can begin working on a project. This project is already built and I'm being brought in to help with front-end work. Problem is I can't get rake db:migrate to do any inserts. Every time I run rake db:migrate I get this:

== 20081220084043 CreateTimeDimension: migrating ==============================
-- create_table(:time_dimension)
   -> 0.0870s
INSERT time_dimension(time_key, `year`, `month`, `day`, day_of_week, weekend, quarter) VALUES(20080101, 2008, 1, 1, 'Tuesday', false, 1)
rake aborted!
Could not load driver (uninitialized constant Mysql::Driver)

I'm building on a MBP with Snow Leopard. I've installed XCode from the disk that comes with the mac. I've updated ruby, installed rails and all the needed gems. I have the 64 bit version of MySQL installed.

I've tried the 32 bit version of MySQL and I've even tried installing from macports.

The mysql gem is installed using: sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/path/to/mysql/bin/mysql_config

the migrate creates the tables just fine but it dies every single time it tries an insert.

Any help would be great

+1  A: 

These instructions for installing MySQL worked great for me on Mac OS X Snow Leopard: http://hivelogic.com/articles/compiling-mysql-on-snow-leopard

John Topley
A: 

Given the error you were getting, it looks like you haven't required the mysql gem. Other potential gotchas:

  1. You forgot to restart your application/server after installing the gem.
  2. You have some sort of problem with the mysql user permissions. (eg: no write privs)
  3. You're using the wrong mysql driver/gem.

Edit: If you're doing ruby dev on Mac, I highly recommend using both homebrew and rvm.

Damien Wilson
A: 

If running 'mysql -u root' on your console works fine, then possibly reinstall your mysql gem using the instructions from hivelogic.com (as per John Topley's link) by typing this instead:

sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql

If you installed MySQL 64-bit as a pkg, try reinstalling by manual compile.

Jen
A: 

Tip on a side: Database migration is bad for seeding. If you use rails >= 2.3.4 then you should use db/seeds.rb and $ rake db:seed task for this.

Eimantas