Rails Migration: Bigint on PostgreSQL seems to be failing?

我们两清 提交于 2019-11-28 08:21:52
Chris Barretto

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.

This works in Rails 4

t.column :really_big_int, :bigint

In rails 4.2 + you can use like:

create_table :table_name do |t|
   t.bigint :really_big_int
end

Rails 5.0.0.1 it works:

  def change
    create_table :huge do |t|  
      t.integer :big_bastard, limit: 8
    end
  end

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).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!