AnApprentice
AnApprentice

Reputation: 111070

Rails - how to store large numbers like 100000076685963

I need to store large numbers like :100000076685963

Which are to big for a db field type of integer. In my db migration I use:

  t.integer :fb_uid

what field type should I use for large numbers like this?

Thanks

Upvotes: 3

Views: 3056

Answers (3)

sameera207
sameera207

Reputation: 16629

Try float

t.float :fb_uid

And seems like this is something to do with Facebook (probably facebooker) and assuming these numbers will not use as arithmetic operations, you could probably use just string

t.string :fb_uid

Upvotes: 3

tamouse
tamouse

Reputation: 2228

You need to set the limit field in for the column to get Postgresql's bigint precision:

t.integer :fb_uid, limit: 8

Upvotes: 1

mbreining
mbreining

Reputation: 7809

You can use a fixed-point datatype such as decimal with a large precision. Based on the number you've given, a precision of 15 will work but you should figure out exactly what range you are expecting.

t.decimal :fb_fluid, :precision => 15

Upvotes: 3

Related Questions