Issue running migrations from MySQL

I’m a little new to migrations, and would appreciate any help…

This is the migration I am attempting to run:

class CreateEmployees < ActiveRecord::Migration
def self.up
create_table :employees do |t|
t.column :id, :integer, :null => false
t.column :user_name, :string, :null => false, :limit => 32
t.column :first_name, :string, :limit => 32
t.column :last_name, :string, :limit => 32
t.column :mod_dt, :datetime, :null => false

def self.down
drop_table :employees

After running ‘rake migrate’, I receive this as an error message:

Mysql::Error: You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to
use near '(11), user_name varchar(32) NOT NULL, first_name
varchar(32) DEFAULT NULL, ' at line 1: CREATE TABLE employees (idint(11) DEFAULT NULL auto_increment PRIMARY KEY(11),user_namevarchar(32) NOT NULL,first_namevarchar(32) DEFAULT NULL,last_namevarchar(32) DEFAULT NULL,mod_dt` datetime NOT NULL)

Correct me if I’m wrong, but it seems that the MySQL error is
happening because the migrations is passing an apostrophe " ’ " around
the column names, i.e. ‘user_name’, ‘id’, etc.

Why would migrations create an incorrect SQL string?

Thanks very much for any help.

I think the ID field is generated automatically.

I got the same error you did, using your code. Removing the ID field
line from the create table block got rid of the error.

Wow, thanks a lot man.