Search code examples
ruby-on-railspostgresql

Error message "Integer out of range" in PostgreSQL database


This is a a simple Ruby on Rails application using a PostgreSQL database, and I am getting 'integer out of range' error when trying to insert 2176968859. It should be an easy fix to the migrations, but I'm not sure. Right now I've got...

create_table :targets do |t|
   t.integer :tid
    ...
end

Solution

  • You are overflowing. Use a bigint if you need numbers that big.

    See 8.1. Numeric Types.