ActiveRecord::StatementInvalid: PG::Error: ERROR: null value in column “id” violates not-null constraint

为君一笑 提交于 2019-11-30 20:12:08

I have same problem once. Here is my problem. I did a

rake db:schema:dump
rake db:schema:load

and the table got problem as below:

create_table "campaign_line_items_backup", :id => false, :force => true do |t|
  t.integer  "id"
  t.integer  "campaign_id"
  t.integer  "size_id"
  t.text     "name"

it should be

create_table "campaign_line_items_backup", :force => true do |t|
  t.integer  "campaign_id"
  t.integer  "size_id"
  t.text     "name"

I am not sure about your problem, That's the way I fixed mine.

The best solution would be retrying Insert operation.

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