22

Trying to create a table with a bigint column creates a standard integer column instead. What could be going wrong? I don't know where to start looking.

I'm using this in the migration:

create_table :table_name do |t|
  t.integer :really_big_int, limit: 8
end

I'm using Ruby 1.9.2, PostgreSQL 9.0.3 and Rails 3.0.9. I've dropped the database and ran the migrations several times and it still doesn't create the bigint column.

Lonecat
  • 2,697
  • 2
  • 17
  • 15
  • Very strange. How are you determining that it creates an integer column—by looking at schema.rb or your PG schema? – dnch Aug 15 '11 at 05:17
  • I'm checking on both places. I just solved it using a string column, although I'm still really curious to know why it wouldn't work. – Lonecat Sep 14 '11 at 04:11
  • 1
    Any update on this, it seems that :limit => 8 is not creating bigint column in Postgres. – Kumar Deepak Jan 15 '12 at 18:17

5 Answers5

28

For some reason the create table doesn't like bigint. You can, however do it with add_columm using the bigint data type:

add_column :table_name, :really_big_int, :bigint

Then you don't need that limit stuff.

Stuart M
  • 11,458
  • 6
  • 45
  • 59
Chris Barretto
  • 9,379
  • 3
  • 42
  • 45
  • 1
    Using Rails 3.2.2 and the `pg` gem (version 0.14.0) this works. Haven't checked in older versions. – Lonecat Dec 20 '12 at 20:30
23

This works in Rails 4

t.column :really_big_int, :bigint
lstefani
  • 385
  • 2
  • 5
8

Rails 5.0.0.1 it works:

  def change
    create_table :huge do |t|  
      t.integer :big_bastard, limit: 8
    end
  end
rmcsharry
  • 5,363
  • 6
  • 65
  • 108
5

In rails 4.2 + you can use like:

create_table :table_name do |t|
   t.bigint :really_big_int
end
Thorin
  • 2,004
  • 1
  • 19
  • 30
1

I was able to create a bigint using t.column. This is useful if you want to control the column order in the table.

create_table :table_name do |t|
  t.string :other_column
  t.column :really_big_int, :bigint
  .
  .
  t.timestamps
end

I'm using Rails 3.2.12 with pg gem version 0.15.1 (x86-mingw32).

Mark Schneider
  • 360
  • 2
  • 10