views:

57

answers:

2

I have a users table with a primary key uid of data type bigint.

I don't understand why I get the error : "Minteger out of range" when trying to add a user with uid = 100000349053153.

This should work (according to the doc: http://www.postgresql.org/docs/8.3/static/datatype.html)

A: 

FWIW the following works just fine for me:

CREATE TABLE bigintexample
(
  id bigint,
  CONSTRAINT pk_bigintexample_id PRIMARY KEY (id)
);

INSERT INTO bigintexample (id) VALUES (100000349053153);
Adam Bernier
A: 

Thanks Nicholas and Adam.

The problem was tied to my confused use of Rails.

I was wrong to think that rake db:reset recreates the database from the migration files. I had the correct migration files but rake db:reset was using the wrong information provided by schema.rb

If you want to store Facebook ID, use (inside your migrations):

t.integer :uid, :limit => 8

You can also add an index:

add_index :users, :uid, :unique => true

And if you want to recreate your Rails database from scratch use:

rake db:drop
rake db:create
rake db:migrate
Pierre Valade