This project is archived and is in readonly mode.

#876 ✓stale
James Le Cuirot

:limit for primary key columns

Reported by James Le Cuirot | August 21st, 2008 @ 12:04 PM | in 3.0.2

The primary key size for MySQL is currently hardcoded to int(11) in ActiveRecord. I have attempted to add support for the :limit option so you can do something like this.


create_table :people, :id => false do |t|
  t.primary_key :id, :limit => 8
  ...
end

The attached patches (for edge and 2.1) make this work for migrations but I had trouble on the schema dumper side of things and gave up because it was getting too messy. Still, we might be able to come up with the right solution through some discussion here.

The problem was that information about the primary key is retrieved through pk_and_sequence_for. This would effectively have to become pk_and_sequence_and_limit_for and the primary key would have to be explicitly given in the create_table block unless the limit size matches the default. This alone wasn't pretty but then I realised I needed access to extract_limit from the MysqlColumn class before the instances of this class are created. Like I said, messy!

So, any ideas?

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages