Trip
Trip

Reputation: 27124

Ruby on Rails workaround for the mySQL max int: 2147483647?

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 ?

Upvotes: 1

Views: 1869

Answers (2)

Dan McNevin
Dan McNevin

Reputation: 22336

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.

Upvotes: 5

Andy
Andy

Reputation: 14194

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

Upvotes: 3

Related Questions