Integer out of range in PostgreSQL database

后端 未结 3 1907
终归单人心
终归单人心 2020-12-17 10:41

I\'m trying to save a number representing the length of a file (4825733517). The column is set to type integer. I don\'t have any validations or restrictions set.

3条回答
  •  庸人自扰
    2020-12-17 11:11

    According to the PostgreSQL documentation an integer have a range from -2147483648 to +2147483647. So your number is to big for this type.

    Update your column and use the parameter limit to indicate that you want to have a bigint.

    change_column :table, :column, :integer, limit: 8
    

提交回复
热议问题