# Issue running migrations from MySQL

**URL:** <https://www.ruby-forum.com/t/issue-running-migrations-from-mysql/86600>\
**Category:** Rails\
**Created:** [February 23, 2007, 5:06pm UTC](https://www.ruby-forum.com/t/issue-running-migrations-from-mysql/86600 "2007-02-23T17:06:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![KendallJ](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a8b319/32.png) [@KendallJ](https://www.ruby-forum.com/u/KendallJ)\
**Post date:** [February 23, 2007, 5:06pm UTC](https://www.ruby-forum.com/t/issue-running-migrations-from-mysql/86600/1 "2007-02-23T17:06:11Z")

</div>

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  
end  
end

def self.down  
drop\_table :employees  
end  
end

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 (`id`int(11) DEFAULT NULL auto_increment PRIMARY KEY(11),`user\_name`varchar(32) NOT NULL,`first\_name`varchar(32) DEFAULT NULL,`last\_name`varchar(32) DEFAULT NULL,`mod\_dt` datetime NOT NULL)  
ENGINE=InnoDB

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.

---

<div class="post-metadata">

**Author:** ![KendallJ](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a8b319/32.png) [@KendallJ](https://www.ruby-forum.com/u/KendallJ)\
**Post date:** [February 23, 2007, 5:40pm UTC](https://www.ruby-forum.com/t/issue-running-migrations-from-mysql/86600/2 "2007-02-23T17:40:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![KendallJ](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a8b319/32.png) [@KendallJ](https://www.ruby-forum.com/u/KendallJ)\
**Post date:** [February 23, 2007, 5:41pm UTC](https://www.ruby-forum.com/t/issue-running-migrations-from-mysql/86600/3 "2007-02-23T17:41:18Z")

</div>

Wow, thanks a lot man.
