I need to index a user table using an identifier from an external source, which is a 64-bit integer. Rails is very good at storing that amount, unless it's a primary key. I have the following migration:
class CreateUsers < ActiveRecord::Migration def change create_table :users, :id => false do |t| t.integer :id, limit: 8 t.string :name t.timestamps null: false end end end
Migration works fine, no errors are reported, but when I try to sow it using a 64-bit integer, they tell me:
RangeError: 76561198054432981 is out of range for ActiveRecord::Type::Integer with limit 4
Obviously, Rails ignores the marginal field if this is the primary key field /: id? How can I handle this?
For what I use sqlite3 (by default), but as far as I know, sqlite is perfectly capable of storing 64-bit integers.
Here's table_info from sqlite:
0|id|integer(8)|0||0 1|name|varchar|0||0 2|created_at|datetime|1||0 3|updated_at|datetime|1||0
source share