Rails - how to store large numbers like 100000076685963

前端 未结 3 981
一个人的身影
一个人的身影 2021-01-14 11:58

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


        
相关标签:
3条回答
  • 2021-01-14 12:20

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

    t.integer :fb_uid, limit: 8
    
    0 讨论(0)
  • 2021-01-14 12:22

    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
    
    0 讨论(0)
  • 2021-01-14 12:33

    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
    
    0 讨论(0)
提交回复
热议问题