In Rails/ActiveRecord 3, how do I change the default primary key type for MySQL?

Posted by jfarmer on Stack Overflow See other posts from Stack Overflow or by jfarmer
Published on 2010-06-22T21:41:58Z Indexed on 2012/06/04 4:40 UTC
Read the original article Hit count: 420

In Rails 3, how do you change the default primary key type to, say, BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY

In my case I'm only interested in MySQL.

For Rails 2, you can see the answer to "How do I use long IDs in Rails?"1

In Rails 3, however, this will throw an error. I'm not sure if that's because the class is no long used, or if the code needs to go in the same place. You can see in active_record/connection_adapters/mysql_adapter.rb that the NATIVE_DATABASE_TYPES constant is still defined.

What's the correct way to achieve the same effect in Rails 3?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby