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

前端 未结 2 1913
没有蜡笔的小新
没有蜡笔的小新 2021-01-05 07:42

I am getting the following error frequently in my application. If I restart my rails application this error will not appear for some time.

Rails - 3.1.3

Ruby

2条回答
  •  北海茫月
    2021-01-05 08:15

    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.

提交回复
热议问题