加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – Rails 3 / Heroku – 在推送到heroku时重置数

发布时间:2020-12-17 02:30:03 所属栏目:百科 来源:网络整理
导读:我正在尝试heroku rake db:使用sqlite3从Rails 3应用程序重置,但是我收到以下错误: rake aborted!PGError: ERROR: type modifier is not allowed for type "text"LINE 1: ...ary key,"name" character varying(255),"content" text(255),... ^ 这是我最近
我正在尝试heroku rake db:使用sqlite3从Rails 3应用程序重置,但是我收到以下错误:

rake aborted!
PGError: ERROR:  type modifier is not allowed for type "text"
LINE 1: ...ary key,"name" character varying(255),"content" text(255),...
                                                             ^

这是我最近的迁移:

change_table :mixes do |t|
  t.change :content,:text
  t.change :post,:text  
end

和我的schema.rb:

create_table "mixes",:force => true do |t|
  t.string   "name"
  t.text     "content",:limit => 255
  t.datetime "created_at"
  t.datetime "updated_at"
  t.string   "mixologist"
  t.string   "link"
  t.string   "title"
  t.text     "post",:limit => 255
end

根据我的理解,Sqlite3不会强制限制字符串和文本,我自己也没有添加这些限制.我认为Heroku会自动处理转换为Postgres或其他任何东西的人.但似乎限制在某个地方抛弃它.对我来说,最好的方法是什么?

如果我发布任何其他内容,请告诉我.

非常感谢.

解决方法

将您最近的迁移更改为

change_table :mixes do |t|   
    t.change :content,:text,:limit => nil
    t.change :post,:limit => nil
end

这是使用sqlite3进行开发时需要注意的许多细微差别之一:(只有当您将字符串的类型从字符串更改为文本时才会发生.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读