Rails 迁移:PostgreSQL 上的 Bigint 似乎失败了? [英] Rails Migration: Bigint on PostgreSQL seems to be failing?

查看:24
本文介绍了Rails 迁移:PostgreSQL 上的 Bigint 似乎失败了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试创建一个带有 bigint 列的表会创建一个标准的整数列.可能出什么问题了?我不知道从哪里开始寻找.

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.

我在迁移中使用它:

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

我使用的是 Ruby 1.9.2、PostgreSQL 9.0.3 和 Rails 3.0.9.我已经删除了数据库并多次运行迁移,但它仍然没有创建 bigint 列.

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.

推荐答案

由于某种原因,create table 不喜欢 bigint.但是,您可以使用 bigint 数据类型通过 add_columm 来执行此操作:

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.

这篇关于Rails 迁移:PostgreSQL 上的 Bigint 似乎失败了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆