views:

64

answers:

2

I'm trying to use this number:

294670251400

This number will be an attribute in a model that is keeping counter tabs on membership cards. The membership cards have three four digit vanity sets.

But when I update_attribute to contain this, the number is reset to mySQL's max int :

2147483647

Anyone have a workaround to this ?

+3  A: 

Are you performing mathematical operations within the database? Can you just store it as a string? or a BIGINT?

Andy
What's a BIGINT? Sounds fun. I can't store it as a string, because I need to perform incrementation on it.
Trip
MySQL Numeric Types: http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html
Andy
Assuming you do the incrementing in ruby code, you could definitely store it as a string. Incrementing would then just be convert to float or integer, add 1, convert to string again. Or use BIGINT :)
nathanvda
I'm assuming that keep it a string would enhance server performance?
Trip
I can't think of a reason why -- BIGINT is 8 bytes, while VARCHAR(n) is n+1 bytes.
Andy
+3  A: 

In your migration, you can specify the integer as such:

  t.integer :really_big_number, :limit => 8

Here's a useful blog post about it.

Dan McNevin