How can I change the (default) type for ActiveRecord\'s IDs? int is not long enough, I would prefer long. I was surprised that there is no :long for the migrations - does on
Borrowing from other solutions, adjusted for what worked for me recently.
Add to a file in config/initializers. It declares a new column type (adapted from chookeat's suggestion).
ActiveRecord::ConnectionAdapters::Mysql2Adapter::NATIVE_DATABASE_TYPES[:long_primary_key] = "BIGINT(20) DEFAULT NULL auto_increment PRIMARY KEY"
Migrations that use a long id are as such:
create_table :notification_logs, :id => false do |t|
t.column :id, :long_primary_key
# ...
end