October 7, 2008

MySQL and Unsigned integer in Rails

Posted by Sudhindra Rao

Rails does not allow you to create unsigned integer in an intuitive way.
For example

t.integer user_id, :unsigned => true

will not work.

To make it work you will have to do http://dev.rubyonrails.org/ticket/5219

t.column user_id, 'integer unsigned'

or use http://brentrubyrails.blogspot.com/2007/11/assigning-custom-data-types-to-new.html

or use the patch.

On Linux you may get a /tmp/mysql.sock not found error to fix that locate mysql.sock(or mysqld.sock)
which should typically be found in /var/run/mysqld/mysqld.sock or /var/local/lib/mysql.sock or some place around. (whereis 'mysql.sock' should be of help here.).
Make sure you add a 'socket: /var/run/mysqld/mysqld.sock' entry in your database.yml for every instance of the database located on the
local machine.

On the network we are in we seem to get an 'EMULTIHOP' error accessing the local instance of mysql.
The fix for that is to add a 'host: 127.0.0.1'. I think this error appears only on networks that have something weird in their DNS.

0 comments:

Welcome